Skip to content

Instantly share code, notes, and snippets.

@prabhuvikas
Created April 15, 2021 05:26
Show Gist options
  • Save prabhuvikas/53f94cf470bc700c0858b5389e0b4220 to your computer and use it in GitHub Desktop.
Save prabhuvikas/53f94cf470bc700c0858b5389e0b4220 to your computer and use it in GitHub Desktop.

virtualenv is a tool to create isolated Python environment

  • Install it via apt-get:
$ sudo apt-get install python3-venv
  • traverse to the project folder
  • create a virtual environment in current directory
$ virtualenv venv
  • this creates a copy of Python in whichever directory you ran the command in, placing it in a folder named venv.
  • to begin using the virtual environment, it needs to be activated
$ source venv/bin/activate
  • install any new modules without affecting system default Python or other virtual environments using pip/pip3
  • generate requirements.txt
$ pip3 freeze > requirements.txt
  • if you are done working in the virtual environment , you can deactivate it
$ deactivate
  • to delete a virtual environment, just delete its folder venv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment