Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sentientmachine/8adc02f8c00f16ba10277390be5a0e98 to your computer and use it in GitHub Desktop.
Save sentientmachine/8adc02f8c00f16ba10277390be5a0e98 to your computer and use it in GitHub Desktop.
Setting up and using Python3 Virtualenv on Mac

MacOS Mojave 10.14.5 Python3.6 Virtualenv setup inside a macbook with python3.7 and default is 3.7

I'm using mac homebrew, I installed thustly:

https://brew.sh/

Baseline python is python3:

You've probably already done this, or it came with the stock macbook:

$ brew install python
$ python3 --version
Python 3.7.3
$ python --version
Python 2.7.16

Make python 3.6 available to the system

brew unlink python
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

pip3 installation:

python3 get-pip.py

virtualenv Installation with pip3

To install virtualenv via pip run:

pip3 install virtualenv

Create a new virtual environment somewhere

Creation of virtualenv:

cd ~/your_project
ln -s /usr/local/Cellar/python/3.6.5_1/bin/python3.6 python3.6
virtualenv -p "/usr/local/Cellar/python/3.6.5_1/bin/python3.6" .env

Activate the virtualenv:

$ cd ~/your_project
$ source .env/bin/activate

Did it verk?

(.env) $ python --version
Python 3.6.5

Deactivate the virtualenv:

$ deactivate

About Virtualenv

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