Skip to content

Instantly share code, notes, and snippets.

@raybesiga
Last active December 19, 2017 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raybesiga/56f413d20083ee6b9cbbdc2836448238 to your computer and use it in GitHub Desktop.
Save raybesiga/56f413d20083ee6b9cbbdc2836448238 to your computer and use it in GitHub Desktop.
Python3 setup and virtualenvs the easy way

Setting up Python3

$ brew install python3

You should then check which version is installed

$ python3 --version

Once Python3 is installed, it comes with Pip3

Installing Virtualenv and Virtualenvwrapper

Next we run the following command:

$ pip3 install virtualenv
$ pip3 install virtualenvwrapper
Directory for Virtualenvs

Usually, you should have a directory where all you virtualenvs reside but in the event that you do not, run the following command:

$ mkdir ~/.virtualenvs

Open your .bashrc and add this directory to the path

export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

Activate these changes by sourcing bash anew

$ source ~/.bashrc

We are now ready to use Python3 and virtualenv wrapper but we need to know on which path it is to use it. Run the following command to find out.

$ which python3

The result most probably looks something like this /usr/local/bin/python3. With this we are ready to create virtualenvs

$ mkvirtualenv --python=/usr/local/bin/python3 mynewvirtualenvname

It shoould now be active

$ (mynewvirtualenvname) ➜  ~

You can deactivate it by simply running the deactivate command:

$ (mynewvirtualenvname) ➜  ~ deactivate

I hope you found this useful. Cheers.

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