Skip to content

Instantly share code, notes, and snippets.

@delwar2016
Created November 18, 2016 03:01
Show Gist options
  • Save delwar2016/0571d0b7f85621076a1109d74500b796 to your computer and use it in GitHub Desktop.
Save delwar2016/0571d0b7f85621076a1109d74500b796 to your computer and use it in GitHub Desktop.
Python
Let’s create a new virtual envirnoment, named myenv, using pyvenv:
pyvenv myenv3
source myenv3/bin/activate
and you can start Python 3 by just typing:
$ python
Note that as you are inside the virtual environment, you don’t need to use the command python3 to open Python 3.
Virtualenvwrapper with Python 3
$ pip install virtualenv
$ pip install virtualenvwrapper
Next, create a folder that will contain all your virtual environments:
$ mkdir ~/.virtualenvs
Open your .bashrc file and add:
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
you can activate these changes by typing
$ source .bashrc
We are ready to create a new virtual environment using Python 3 with
$ mkvirtualenv --python=python3_path myenv3
where python3_path is the path of python3, which can be found with
$ which python3
in my case it was
$ mkvirtualenv --python=/usr/local/bin/python3 myenv
This creates a folder myenv inside the environments folder ~/.virtualenvs.The new environment will be active after running the previous command. To deactivate it, just type:
$ deactivate
and to activate it again
$ workon myenv
While being in your python3 virtual envirnoment, if you type
$ python
Original Link:
http://www.marinamele.com/2014/07/install-python3-on-mac-os-x-and-use-virtualenv-and-virtualenvwrapper.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment