Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akkefa/e90f1a94b61388b860f49409ef0bd080 to your computer and use it in GitHub Desktop.
Save akkefa/e90f1a94b61388b860f49409ef0bd080 to your computer and use it in GitHub Desktop.
python3.6 setup on Mac 10.13 (High Sierra)
  1. Install Python 3.6.x from https://www.python.org/downloads/ or via homebrew
    Check that python3 has been installed by running it at the terminal:
$ python3
>>> Python 3.6.4
  1. Download get-pip.py from https://bootstrap.pypa.io/get-pip.py and install (this should already be installed if python was installed from python.org or homebrew):
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py
  1. Install virtualenv and virtualenvwrapper
$ sudo -H pip3 install virtualenv
$ sudo -H pip3 install virtualenvwrapper --ignore-installed six
  1. Add the following to your ~/.bash_profile to load virtualenvwrapper then run bash -l
if [ -e /usr/local/bin/virtualenvwrapper.sh ]; then
  source /usr/local/bin/virtualenvwrapper.sh
fi
  1. Create your virtual enviornment named py3
$ mkvirtualenv --python=`which python3.6` py3
/*
* To install all modules: pip3 install -r requirements.txt
*/
bokeh
Flask
ipython
jupyter
keras
matplotlib
nose
numpy
pandas
Pillow
pymc
requests
scikit-image
scikit-learn
scipy
seaborn
statsmodel
tensorflow

Installing opencv3 with python3.6

$ brew update
$ brew install opencv3 --with-python3   # Add --with-contrib if you want the contrib modules
$ ln -s /usr/local/opt/opencv3/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so /usr/local/lib/python3.6/site-packages/cv2.so

You may have to export PYTHONPATH:

export PYTHONPATH=$PYTHONPATH:/usr/local/Cellar/opencv3/3.4.0/lib/python3.6/site-packages

If you installed a previous version of opencv and no longer need it, remove it:

brew cleanup opencv

Test:

$ python3
In[1]: import cv2
In[2]: cv2.__version__
Out[2]: '3.4.0'

Install these modules from Github as their py3 support is currently not published on PyPI. Their master branch works with Python3.6

Set your locale in an environment variable in ~/.bash_profile

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Type bash -l in your terimal to run the updated bash_profile.
Now, install the modules:

$ pip3 install git+git://github.com/cython/cython@master
$ pip3 install git+git://github.com/statsmodels/statsmodels
$ pip3 install git+git://github.com/pymc-devs/pymc3
$ brew install llvm
$ brew link llvm --force
$ pip3 install numba

Test code from numba

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