Python Virtual Environments
Conda and PIP
Nov 25, 2021
Packages list with versions saving using Pip
pip list
# shows the packages
pip freeze > requirements.txt
# save all packages
To create a virtual environment with the above packages
python3 -m venv myEnv
source myEnv/bin/activate
pip install -r requirements.txt
Packages list with versions saving using Conda
conda list
# shows packages list
# save all packages either in txt
or yaml
file. yaml
is better and commonly used
conda list -e requirements.txt
conda env export > myEnv.yml
To create a virtual environment with the above packages
conda create — name myEnv— file requirements.txt
or
conda env create -f myEnv.yml