I have been using conda virtual environment for a while and always heard about python virtual environment without giving it a try. But I found out recently that this could be a very easy way to setup an environment automatically with a library when releasing it. Here is an introduction on how that guy works.
To create a new environment, go inside your library and do
$ python -m venv py36_environment
where py36_environment is the name of my new environment.
This will create a folder named py36_environment inside our project with the following structure.
Here is what each folder contains:
- bin: files that interact with the virtual environment
- include: C headers that compile the python packages
- lib: a copy of the python version along with a site-packages folder where each dependency is installed
To switch to that environment
$ source py36_environment/bin/activate
the prompt is now prefixed with the name of our new environment.
and to deactivate this one
pyvenv does not allow to install different versions of python. To do so, use conda environment.