Mac : OS X Yosemite(10.10.1)
A very useful package management tool for Mac Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Python version control tool pyenv
#Install pyenv
brew install pyenv
Next, set the PATH. Add the following settings to .zshrc and .bashrc.
#Setting environment variables
export PATH="$PYENV_ROOT/bin:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
eval "$(pyenv init -)"
If you are using fish shell, add the following line instead of the last line in ↑ (~ / .config / fish / config.fish
)
# pyenv
status --is-interactive; and . (pyenv init -| psub)
What is Anaconda?
Anaconda is a free distribution of various packages for building a Python numerical calculation environment.
By installing, NumPy, SciPy, matplotlib, of course,
Machine learning library scikit-You can install packages such as learn.
You can check the version of Python that can be installed with the following command
#View a list of installable Python
pyenv install -l
Select the latest Anaconda (anaconda-3-2.1.0) from the list and select [as of November 25, 2014] Install Anaconda with the following command.
The default of Anaconda is Python3 series.
#Installation of Anaconda
pyenv install anaconda3-2.1.0
After installation, type the following command
pyenv rehash
After restarting the terminal (just in case)
#List of available Python
pyenv versions
(output)
* system
anaconda3-2.1.0 (set by /Users/yourname/.pyenv/version)
If, anaconda is installed normally.
Next, set the Python to use
#Python settings to use
pyenv global anaconda3-2.1.0
(output)
/Users/yourname/.pyenv/versions/anaconda3-2.1.0/bin/python
#Check the current Python version
pyenv version
(output)
anaconda3-2.1.0 (set by /Users/yourname/.pyenv/version)
#Confirmation of python reference source
which python
(output)
/Users/yourname/.pyenv/versions/anaconda3-2.1.0/bin/python
Once the settings are complete,
conda update conda
Let's update Anaconda itself
This completes the installation of Anaconda on Python 3 series.
conda create -n py27 python=2.7 anaconda
Then you can install python2.7 Anaconda with the name py27 (py27 part is any name)
If you want to use this environment
source ~/.pyenv/versions/anaconda3-2.1.0/bin/activate py27
Then you can use it.
It is troublesome to type this long line every time, so it is convenient to set the following in the terminal configuration file.
alias py2='source ~/.pyenv/versions/anaconda3-2.1.0/bin/activate py27'
alias py3='source ~/.pyenv/versions/anaconda3-2.1.0/bin/deactivate'
If you check the Python version in a normal terminal state, And Python3 series
Next, when I check the version of Python after activating the environment of python2.7, It is properly Python 2 series
After making the environment of python2 system,
conda install opencv
As in the file or on ipython
import cv2
Then you will be able to use OpenCV with Python2 system.
pyenv rehash
It automates the mysterious magic
# pyenv-pip-install rehash
git clone https://github.com/yyuu/pyenv-pip-rehash.git ~/.pyenv/plugins/pyenv-pip-rehash
Building a Python machine learning environment on Mac (May 2014 version)
How to install 2 Anacondas (Python 2.7 and 3.4) on Mac OS 10.9
Introduction of Python numerical calculation environment Anaconda
When putting in usr / local
#Setting environment variables
export PYENV_ROOT="/usr/local/opt/pyenv"
#pyenv code completion
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi