Set up pyenv, a tool that allows you to install various Python versions and implementations in parallel, such as CPython 2.7 and 3.3, jython and pypy.
$ brew install pyenv-virtualenv pyenv
Also install pyenv-pip-rehash, which also rehashes.
$ git clone https://github.com/yyuu/pyenv-pip-rehash.git ~/.pyenv/plugins/pyenv-pip-rehash
Describe in the configuration file (.bashrc, .zshrc, etc) corresponding to your login shell according to the following
.zshrc
To enable shims and autocompletion add to your profile:
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
To use Homebrew's directories rather than ~/.pyenv add to your profile:
export PYENV_ROOT=/usr/local/opt/pyenv
$ pyenv install -l
Available versions:
2.4
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
...abridgement...
pypy-2.0-src
pypy-2.0.1
pypy-2.0.1-src
pypy-2.0.2
pypy-2.0.2-src
pypy-2.1
pypy-2.1-src
pypy-2.2
pypy-2.2-src
pypy-2.2.1
pypy-2.2.1-src
pypy-dev
pypy3-2.1-beta1
pypy3-2.1-beta1-src
pypy3-dev
stackless-2.7-dev
stackless-2.7.2
stackless-3.2-dev
stackless-3.2.2
stackless-3.3-dev
stackless-dev
$ pyenv install 2.7.6
$ pyenv install 3.3.3
$ pyenv install pypy-2.2.1
$ pyenv versions
* system (set by /Users/tstomoki/.pyenv/version)
2.7.6
3.3.3
####Switch current shell version
$ pyenv shell 2.7.6
#Switch version of current directory
$ pyenv local 2.7.6
#Overall version switching
$ pyenv global 2.7.6
I would like to install numpy, scipy, matplotlib, etc., which are mainly used for data analysis.
Also install gfortran for scripy
$ brew install gfortran
$ pip install numpy
$ pip install yamlog
$ pip install scipy
$ pip install matplotlib
In the middle
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 46: ordinal not in range(128)
I got the error, but I solved it with this page. (Write the following in ~ / .pyenv / versions / 2.7.6 / lib / python2.7 / site-packages / sitecustomize.py)
sitecustomize.py
import sys
sys.setdefaultencoding('utf-8')
Also, I got the error "/System/Library/Frameworks/vecLib.framework/Headers/vBasicOps.h:153:23: error: immintrin.h: No such file or directory" and scipy installation failed [this page] From](https://github.com/scipy/scipy/issues/3194) It was solved by exporting the following. It seems that it was a problem with the Xcode header.
$ export CC=clang
$ export CXX=clang
$ export FFLAGS=-ff2c
I got angry when installing matplotlib, so on this page (http://stackoverflow.com/questions/20572366/sudo-pip-install-matplotlib-fails-to-find-freetype-headers-os-x-mavericks) I put a link of freetype2 like this.
$ ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype
test.py
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
savefig("test.png ")
show()
$ python test.py
If the sine curve is output, the installation of python and pip is complete.
-Put matplotlib in Mac mountain lion
Recommended Posts