Skip to content

Instantly share code, notes, and snippets.

@evansneath
Last active March 7, 2022 16:31
Show Gist options
  • Star 44 You must be signed in to star a gist
  • Fork 30 You must be signed in to fork a gist
  • Save evansneath/4582716 to your computer and use it in GitHub Desktop.
Save evansneath/4582716 to your computer and use it in GitHub Desktop.
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
@arindam31
Copy link

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.

@jmsv
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