0% found this document useful (0 votes)
29 views

Python Virtual Environments

The document discusses virtualenvwrapper, a tool that helps manage Python virtual environments. It describes how to install virtualenvwrapper, configure it by adding lines to the .bashrc file, and use commands like workon, deactivate, mkvirtualenv, and rmvirtualenv to create, activate, deactivate, and remove virtual environments. Virtual environments allow isolating package installations for each project to avoid conflicts between dependencies.

Uploaded by

Milind
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Python Virtual Environments

The document discusses virtualenvwrapper, a tool that helps manage Python virtual environments. It describes how to install virtualenvwrapper, configure it by adding lines to the .bashrc file, and use commands like workon, deactivate, mkvirtualenv, and rmvirtualenv to create, activate, deactivate, and remove virtual environments. Virtual environments allow isolating package installations for each project to avoid conflicts between dependencies.

Uploaded by

Milind
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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