This article was originally published on freeCodeCamp, you can read the full article here.
I have over two decades of professional experience as a developer, I know a wide variety of frameworks and programming languages, and one of my favorites is Python. I’ve been teaching it for quite some time now, and according to my experience, establishing Python environments is a challenging topic.
Thus, my main motivation for writing this article was to help current and potential Python users to have a better understanding of how to manage such environments.
If you’ve opened this article, chances are that you already know what Python is, why it is a great tool, and you even have a Python installed on your computer.
So why exactly do you need Python environments? You might ask: shouldn’t I just install the latest Python version?
Why you need multiple Python environments
When you start learning Python, it is a good starting point to install the newest Python version with the latest versions of the packages you need or want to play around with. Then, most likely, you immerse yourself in this world, and download Python applications from GitHub, Kaggle or other sources. These applications may need other versions of Python/packages than the ones you have been currently using.
In this case, you need to set up different so-called environments.
Aside from this situation, there are more use cases when having additional environments might come in handy:
- You have an application (developed by yourself or by someone else) that once worked beautifully. But now you’ve tried to run it, and it is not working. Perhaps one of the packages is no longer compatible with the other parts of your program (due to the so-called breaking changes). A possible solution is to set up a new environment for you application, that contains the Python version and the packages that are completely compatible with your application.
- You are collaborating with someone else, and you want to make sure that your application is working on your team member’s computer, and vice versa, so you can also set up an environment for your co-worker’s application(s).
- You are delivering an application to your client, and again, you want to make sure that it is working smoothly on your client’s computer.
An environment consists of a certain Python version and some packages. Consequently, if you want to develop or use applications with different Python or package version requirements, you need to set up different environments.
This article also covers the following topics (you can read the full article here):
How to choose an appropriate Conda download option
- Python environments: root and additional
- Directory structure
- GUI vs. Command line (Terminal)
- Managing environments
- Managing packages