Skip to content

Python

Virtual Environment#

Create Virtual Environment#

To create a virtual environment execute the following command:

python3 -m venv .venv
This will create a new folder .venv in the current working directory containing the virtual environment with the Python interpreter and pip pre-installed.

Activate Virtual Environment#

To use the newly created virtual environment execute one of the following commands based on the shell you are using:

  • bash:
    source .venv/bin/activate
    
  • fish:
    . .venv/bin/activate.fish
    

Requirements Files#

Create Requirements Files#

python3 -m pip freeze > requirements.txt

Install From Requirements File#

python3 -m pip install -r requirements.txt

References#


Last update: 2020-10-03