Python: Virtual Environments
There may be a situation when you need to work/contribute to multiple python projects that use different python versions and other libraries. In that scenario, it is not recommended
to use the system-installed
python version but to create separate virtual environments
for each project
to manage each project's dependencies
.
A virtual environment is a Python environment such that the Python interpreter, libraries, and scripts installed into it are isolated from those installed in other virtual environments, and (by default) any libraries installed in a “system” Python, i.e., one which is installed as part of your operating system
There are different ways to create a virtual environment for python. In this blog, I am going to explain how you can use Pyenv to create a virtual environment. However, we can also use Poetry in the virtual environment and venv
I am going to explain the steps for mac os. However, you can refer to the documentation for other operating systems.
let's start
- Consider installing with Homebrew:
2. Pyenv