Python Starting to Learn Python: Development Tools and Environments

  • Thread starter Thread starter PeroK
  • Start date Start date
  • Tags Tags
    Python Tools
Click For Summary
Learning Python can be initiated effectively using various IDEs and editors, with PyCharm Community Edition and Anaconda being highly recommended for beginners. Anaconda simplifies package management and deployment, making it suitable for scientific computing and data science. Users can also opt for Jupyter Notebooks for an interactive coding experience. While some prefer command-line tools and lightweight editors like Notepad++, others appreciate the debugging features and user-friendly interfaces of IDEs like Spyder and Thonny.For Windows users, familiarity with the operating system is beneficial, although IDEs can abstract some complexities. Git is widely used for source control, with platforms like GitHub and Bitbucket available for hosting repositories. Python 3 is emphasized over Python 2 due to ongoing deprecation. For GUI development, TkInter is built-in, but wxPython is recommended for more robust applications. Overall, the choice of tools depends on personal preference and specific programming goals, with many resources available for beginners to ease the learning curve.
  • #31
A lot of suggestions here and all are sensible, I think. Python has so many good tools. :-)

I probably would start with Jupyter notebooks (and anaconda). It's very interactive to program with them and they allow you to quickly explore math, plot things and dig into data. If you want to go the more traditional road of working with scripts, I recommend Spyder (or thonny which looks even more beginner-friendly but I don't have any experience with it myself). PyCharm is also a great program but I would only use it as a beginner if I was interested in getting to a professional level with bigger projects (like websites) quickly.
 
Technology news on Phys.org
  • #32
One of the downsides I have faced when working with Spyder and the like, is that you can execute parts of the script you are writing by selecting it with the mouse and clicking on a button. It is a nice feature you don't have when using the command-line, however the variables are kept in memory. In the end when you execute the whole document, it may work only because some variables are still in memory, creating an illusion that the whole file.py is "working as expected". Then, when you execute the code from the command-line, errors are returned. I have faced this problem so many times that I feel I have to mention it.

Personally I just use Gedit + command line or neovim + command line. Spyder (with Anaconda I think) only when I am forced to use Windows on a machine that is not mine.
 
  • #33
Get around the Spyder keeping the variables in memory by clearing out the variables. Sure, the command line works, but when tracing a code one line at a time, the ability to step thru it in an IDE is completely beneficial.
 
  • Like
Likes pbuk
  • #34
Dr Transport said:
Get around the Spyder keeping the variables in memory by clearing out the variables. Sure, the command line works, but when tracing a code one line at a time, the ability to step thru it in an IDE is completely beneficial.
It's not necessary to be using an IDE with Python to get debugging capabilities. You can step through the code from the command line using the PDB debugger that comes with Python distributions. I wrote two Insights articles on how to use this tool.
https://www.physicsforums.com/insights/simple-python-debugging-pdb-part-1/
https://www.physicsforums.com/insights/simple-python-debugging-pdb-part-2/
 
  • Like
Likes berkeman, atyy, Locrian and 2 others
  • #35
PeroK said:
I finally decided to learn how to program in Python. ... I don't want to get into installing Linux at this stage. Do I need to be able to find my way around the Windows O/S, or does an IDE make that unnecessary?
Have you considered getting a single-board computer like Raspberry Pi? It will come with a full Lenix OS and there are a great many introductory tutorials and projects. They are fairly cheap and yet reasonably powerful.
 
  • #36
FactChecker said:
Have you considered getting a single-board computer like Raspberry Pi?
I haven't.
 
  • #37
Mark44 said:
It's not necessary to be using an IDE with Python to get debugging capabilities. You can step through the code from the command line using the PDB debugger that comes with Python distributions. I wrote two Insights articles on how to use this tool.
https://www.physicsforums.com/insights/simple-python-debugging-pdb-part-1/
https://www.physicsforums.com/insights/simple-python-debugging-pdb-part-2/

To be honest, that's a couple of insights I have not read. Thanks for giving me that info.
 
  • #38
PeroK said:
I haven't.
I bought one back in April and it was a lot of fun, but ended up burning it out two months later. You can install python on windows just fine and use visual studio which is a great IDE.
 
  • Like
Likes FactChecker and PeroK
  • #39
Borg said:
Anaconda with Jupyter Notebooks.
This is mostly, AFAIK, for Data Science/Analytics. @PeroK : Any specific goal/focus in learning Python ? Edit: There are other more " neutral ones" like Idle ( Part of the Python theme, I guess: Idle--Eric ). I was having some conflict for a while using versions 2,3 at the same time. When you make a request to the back end server , at least from Anaconda, the system got confused on which of the servers 2,3 would handle/serve the request.
 
  • #40
WWGD said:
This is mostly, AFAIK, for Data Science/Analytics. @PeroK : Any specific goal/focus in learning Python ? Edit: There are other more " neutral ones" like Idle ( Part of the Python theme, I guess: Idle--Eric ). I was having some conflict for a while using versions 2,3 at the same time. When you make a request to the back end server , at least from Anaconda, the system got confused on which of the servers 2,3 would handle/serve the request.
I've no programming project in mind, but I wanted to be able to write some mathematical scripts to help when looking at various problems. I assumed Python would be quick and easy to get started with.
 
  • #41
That's Python's strength: you can produce functional, usable code very quickly.

Ensuring that code runs fast, on the other hand, is something of an art. Python can run fast, but sometimes doesn't. There are a lot of opportunities for bottlenecks.
 
  • #42
PeroK said:
I've no programming project in mind, but I wanted to be able to write some mathematical scripts to help when looking at various problems. I assumed Python would be quick and easy to get started with.
In that case, download python from the Windows store and an editor (Notepad++ is nice) and start coding. You will almost certainly want numpy and scipy, but their webpages have install instructions.

Worry about IDEs when you're writing large projects.
 
  • #43
Well with Anaconda you get everything in a single package (python with numpy, scipy, IDE,...) which is good enough to start and also for more advanced topics.
I agree with Ibix, that if you want GUI programming the built-in Tkinter is.. well let's just say, not appealing :)
 
  • #44
On linux and Mac python is part of the system and it can easily be broken. I would suggest looking into virtual environments. The value is that if you screw one up just delete it and start afresh. I hate IDEs. They just get in the way typically.
 
  • #45
Just to recap, we are on Windows (read the OP) and at the advice from at least two posters in this thread experienced in multiple environments have recommended FOR THIS USE CASE the Anaconda installation which comes packaged with Jupyter Notebooks and/or PyCharm which is a cut-down version of a commercial product.

Python package management in Windows is a mess, and it is far quicker to let the Anaconda or Intellij installer set this up so it works than debug a self-installation of Python and pip or conda.
 
  • #46
pbuk said:
Python package management in Windows is a mess, and it is far quicker to let the Anaconda or Intellij installer set this up so it works than debug a self-installation of Python and pip or conda.

I disagree about package management on Windows being a mess. I use git bash and python venv on Windows and it works very smoothly. I totally get a preference for other tools, but one can work very efficiently without them.
 
  • Like
Likes atyy and Paul Colby
  • #47
Locrian said:
I disagree about package management on Windows being a mess. I use git bash and python venv on Windows and it works very smoothly. I totally get a preference for other tools, but one can work very efficiently without them.
That's great, I'm glad it works for you. Have you ever tried to fix it for someone else, remotely, with an unknown environment state?
 
  • Like
Likes atyy
  • #48
(of course whilst this discussion has being continuing, the OP has just been getting on with coding in Python - good for you @PeroK)
PeroK said:
PS I've downloaded Pycharm and will see how that goes.
 
  • #49
pbuk said:
That's great, I'm glad it works for you. Have you ever tried to fix it for someone else, remotely, with an unknown environment state?

As long as Python and git bash are installed, this would just be typing three lines into the bash terminal.

There's nothing special about Python package management on Windows. Venv even uses the same syntax as Linux (the only difference being the activation script is stored in youenvfolder/Scripts instead of yourenvfolder/bin). If memory serves me, conda environment management uses the same syntax in git bash and linux as well, though I haven't needed conda for a couple of years.
 
  • Like
Likes Paul Colby
  • #50
Locrian said:
As long as Python and git bash are installed, this would just be typing three lines into the bash terminal.

There's nothing special about Python package management on Windows. Venv even uses the same syntax as Linux (the only difference being the activation script is stored in youenvfolder/Scripts instead of yourenvfolder/bin). If memory serves me, conda environment management uses the same syntax in git bash and linux as well, though I haven't needed conda for a couple of years.
The problem is that in Windows there is no such thing as "yourenvfolder".

pip or conda looks for packages in the locations that are set in the PATH (or is it Path now? was it ever case sensitive anyway?) env variable visible to the current application instance, and the only way this is going to be set right is if whatever you used to install Python put them there and there is not some other install that has overwritten them or put another version over the top or higher up the precedence or on another user or in an inaccessible Admin user or in a bespoke "Python" shortcut or somewhere else.
 
  • #51
pbuk said:
The problem is that in Windows there is no such thing as "yourenvfolder".

Sure there is!

Here's the exact code I would type to create and activate it in git bash:

Code:
python -m venv envs/physicsforum
source envs/physicsforum/Scripts/activate

The first line creates a "phsysicsforum" folder in my "envs" folder. Envs is where I keep all my environments; you can put yours somewhere else. You can even place it in your repo, though that's generally inadvisable. You might need to do so if you're leveraging lambda or other serverless tool.

The second line activates that folder in my path, just as you say needs to be done.

When I'm done with that environment, i can activate another one or type "deactivate" to return to defaults.

I keep an activate.env bash script in each of my repos that does the "source" command, so I don't have to type it in every time.
 
  • Skeptical
Likes pbuk
  • #52
Locrian said:
Sure there is!...
I don't doubt that your solution works for you, however it is solving a different problem to the one we are discussing here, namely:
  • Starting to Learn Python
  • I've never programmed (or done anything technical) on Windows
  • I don't want to get into installing Linux at this stage
 
  • #53
I haven't suggested installing linux, just git bash. If you don't like the git bash terminal, you can use the windows terminal to do the same thing (it will even give you that option when you install git bash).

The important thing I want folks to take away from this is that there's nothing magical about the Python environment. There's no Windows Python package management system or something like that.

Python package management consists of
1) A folder (with a specific subfolder structure)
2) A way to get code into that folder, compiling when necessary (and with the right structure)
3) A way to point Python to that folder

There are programs that obscure this in the name of ease, and there's nothing wrong with using them. . . until they don't work. Then if you don't understand what's happening behind the scenes, it can all seem very mysterious and hard to solve.
 
  • #54
python actually comes with a very simple "ide" on windows.
 
  • #55
Dr Transport said:
Spyder coupled with Anacondais a good IDE. I use it all the time and it has served me well. Works on both Windows and Linux.
How is Spyder different from Jupyter notebooks?
 
  • #56
WWGD said:
How is Spyder different from Jupyter notebooks?

I couldn't tell you, I've never used a Jupyter notebook.
 
  • Like
Likes WWGD
  • #57
Spyder is a different experience than a notebook - it isn't a web application, and doesn't have the same options for graphics, narrative text, etc. within the code. However, like a notebook, it does keep a kernel running, which can allow for some very nice debugging options. Spyder will feel more like Pycharm to those used to Jupyter.

My only complaint with Spyder is that, for reasons that I cannot fathom, it takes absolutely forever to spin up on my work machine. Like, 3-10 minutes. It comes right up at home, so I assume it's the anti-virus or some similar program getting in the way.
 
  • Like
Likes WWGD

Similar threads

  • · Replies 1 ·
Replies
1
Views
8K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
7
Views
1K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
6
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K