Skip to content

Instantly share code, notes, and snippets.

@Utshaw
Last active February 7, 2021 19:08
Show Gist options
  • Save Utshaw/cdf271d5b805c691a816f1841da40427 to your computer and use it in GitHub Desktop.
Save Utshaw/cdf271d5b805c691a816f1841da40427 to your computer and use it in GitHub Desktop.
Python-virtualenv-commands
# ref: https://www.youtube.com/watch?v=N5vscPTWKOk
sudo apt-get install python3-pip
sudo pip3 install virtualenv
virtualenv project_virtual_env # create a virtual environment on current python folder
source ./project_virtual_env/bin/activate # activate virtual environment
which python # now see, python refers to current environment's python
pip list # list all packages on this environment
pip freeze --local # show local dependencies on python environment
pip freeze --local > requirements.txt # Output those to a txt file
deactivate # Get out of virtual environment
rm -rf project_virtual_env
virtualenv -p usr/bin/python project_2_virtual_env # use specific version of python instead of default one
source project_2_virtual_env/bin/activate
pip install -r requirements.txt # install packages from requirements.txt to this virtual environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment