Skip to content

Instantly share code, notes, and snippets.

@vlee-harmonicinc
Last active July 15, 2020 02:29
Show Gist options
  • Save vlee-harmonicinc/a90087364fbb361b0b6e181d82e2c75f to your computer and use it in GitHub Desktop.
Save vlee-harmonicinc/a90087364fbb361b0b6e181d82e2c75f to your computer and use it in GitHub Desktop.
Python virtual environment tools

Python virtual Env

virtualenv

lightweight(poor man) isolation via modifying PATH to prefix it with custom bin docs

pip3 install virtualenv # isntall virtualenv
cd <repo>
virtualenv <venv> # create new environment <venv>
source venv/bin/activate # enter virtual env
pip install -r requirements.txt # install all python modules
<processing...>
deactivate # leave env
rm -r <venv> # to cleanup virtual env, simply delete the directory

venv

standard library after python 3.4. (previously is pyvenv)

pyenv

isolate Python version.

conda

virtual enviroment + pip package management + default data-science packages could switch python version

miniconda

mini version conda, less packages

docker

container under same OS. could move the whole env to other machine. Good for deploy any type of program.

virtual machine, VM

whole OS

I perfer virtualenv (venv) and docker, based on use case and premission/pre-installed program in the computer. conda is too heavy with default data-science packages, which could easily installed with pip -r requirements.txt if required. I do not need its GUI tools when remoting server/ GPU instances. Also, Python 2 is not under-maintain anymore. Python 3 projects usually do not need to specific minor version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment