Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Python Virtual Environments

virtualenvwrapper

$pip install virtualenvwrapper

For Windows use virtualenvwrapper-win instead

Add the following lines to .bashrc

export WORKON_HOME=$HOME/.virtualenvs # Optional

export PROJECT_HOME=$HOME/projects # Optional


source /usr/local/bin/virtualenvwrapper.sh

After modifying .bashrc, source it

$source .bashrc

Following new commands are available in the shell:

● workon
● deactivate
● mkvirtualenv
● cdvirtualenv
● rmvirtualenv

To start a new project: $ mkvirtualenv my-new-project

(my-new-project) $

This will create and activate a new environment in the directory located at

$WORKON_HOME, where all virtualenvwrapper environments are stored.

To stop using that environment, just deactivate it:

(my-new-project) $ deactivate

1
If you have multiple environments, you can list them all with the workon function:

$ workon

My-new-project

My-dash-project

Web-scraper

To activate one of them:

$ workon My-dash-project

(My-dash-project) $

Reference: https://realpython.com/python-virtual-environments-a-primer/

You might also like