Reputation: 583
We're building code that we want to run on both Python 2 & 3. It uses matplotlib. My local machine runs OS X Yosemite.
The matplotlib installation documentation provides instructions for both python 2 & 3, but implies that both cannot be supported on a single Mac. Is this true, and if not how can both be supported with matplotlib?
(Parenthetically, I know that separate installations can be made with virtual environments or machines. However, I've found these cumbersome on Macs. On the other hand, I'm also testing builds on a commercial cloud-based build tester that uses separate VMs for each configuration, which works reasonably well.)
Upvotes: 0
Views: 598
Reputation: 86320
I too find virtualenvs annoying for this sort of thing, and have run into strange issues on OSX virutalenvs with matplotlib in particular.
But there is a really nice tool for supporting parallel installations of different package & python versions: conda
. It will manage parallel environments with any Python version; for your case you can do the following:
Install miniconda
Create a Python 3 environment: conda create -n py3env python=3.5 matplotlib
Create a Python 2 environment: conda create -n py2env python=2.7 matplotlib
Activate the one you want with, e.g. source activate py2env
And you're ready to go. For more information on conda environments, see the conda-env docs.
Upvotes: 1
Reputation: 583
This appears to work:
python 3: install https://www.python.org/ftp/python/3.5.2/python-3.5.2-macosx10.6.pkg
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
pip3 install nose
pip3 install matplotlib
pip3 install cobra
pip3 install numpy
pip3 install scipy
pip3 install openpyxl
pip3 install future
pip3 install recordtype
pip3 install lxml
pip3 install python-libsbml
python 2: install https://www.python.org/ftp/python/2.7.12/python-2.7.12-macosx10.6.pkg
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
sudo pip2 install nose
sudo pip2 install matplotlib
sudo pip2 install cobra
sudo pip2 install numpy
sudo pip2 install scipy
sudo pip2 install openpyxl
sudo pip2 install future
sudo pip2 install recordtype
sudo pip2 install lxml
sudo pip2 install python-libsbml
sudo pip2 uninstall python-dateutil # deal with bug in six; see http://stackoverflow.com/a/27634264/509882
sudo pip2 install python-dateutil==2.2
Upvotes: 0