Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setting up and using Python3 Virtualenv
To install virtualenv via pip
$ pip3 install virtualenv
Note that virtualenv installs to the python3 directory. For me it's:
$ /usr/local/share/python3/virtualenv
Create a virtualenvs directory to store all virtual environments
$ mkdir somewhere/virtualenvs
Make a new virtual environment with no packages
$ virtualenv somewhere/virtualenvs/<project-name> --no-site-packages
To use the virtual environment
$ cd somewhere/virtualenvs/<project-name>/bin
$ source activate
You are now using the virtual environment for <project-name>. To stop:
$ deactivate
Copy link

arindam31 commented Jul 26, 2017

Do I need to install Python35 before I create the virtualenv? My requirement is temporary. Test some python scripts which are designed for Python 3.5. I thought with virtualenv, I will install Python3.5 , do my thing and then delete the env.

Copy link

jmsv commented Oct 4, 2017

After running pip3 install virtualenv and then which virtualenv, the path is to '/usr/local/bin/virtualenv'. Does this mean that running virtualenv is creating a python2 environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment