This is a training to become a data scientist using Python. Let's start by building an environment that runs Python. The Python environment we are aiming for this time is as follows. Mac OS + Homebrew + pyenv + Anaconda
[My execution environment] OS X El Capitan (10.11.6)
** NEXT ** → [Python] Road to snake charmer (2) Basics of Python
Homebrew Homebrew is a package management system that makes it easy to install software on Mac OS. This time I will use it to install pyenv. If you have already installed it, please skip it.
Just paste the following script into your terminal and run it.
Terminal
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If you can confirm the version with the following command, the installation is successful.
Terminal
$ brew -v
Homebrew 1.1.0
Let's update so as not to be left behind in the times.
Terminal
$ brew update
pyenv Next is pyenv. pyenv is a version control tool that allows you to ** transcend ** and easily install and switch between different versions of Python. This is essential because Python is the ** strongest language ** where version 2 is still being used even though version 3 is the latest.
pyenv can be installed using Homebrew.
Terminal
$ brew install pyenv
If this is all, it cannot be used yet, so reload it through path.
Terminal
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
$ exec $SHELL
If you can confirm the version with the following command, the installation is successful.
Terminal
$ pyenv -v
pyenv 1.0.2-46-geb2e5ac
Anaconda It's finally Python installation. However, Python is installed with Anaconda. Anaconda is a set of libraries required for data scientists with Python itself ** Transcendental lewd ** package. It's pretty lewd, so if you put this in, it's almost OK.
Anaconda is installed with pyenv. First, check the latest version that can be installed.
Terminal
$ pyenv install -l | grep anaconda
anaconda-1.4.0
anaconda-1.5.0
anaconda-1.5.1
anaconda-1.6.0
anaconda-1.6.1
anaconda-1.7.0
anaconda-1.8.0
anaconda-1.9.0
anaconda-1.9.1
anaconda-1.9.2
anaconda-2.0.0
anaconda-2.0.1
anaconda-2.1.0
anaconda-2.2.0
anaconda-2.3.0
anaconda-2.4.0
anaconda-4.0.0
anaconda2-2.4.0
anaconda2-2.4.1
anaconda2-2.5.0
anaconda2-4.0.0
anaconda2-4.1.0
anaconda2-4.1.1
anaconda3-2.0.0
anaconda3-2.0.1
anaconda3-2.1.0
anaconda3-2.2.0
anaconda3-2.3.0
anaconda3-2.4.0
anaconda3-2.4.1
anaconda3-2.5.0
anaconda3-4.0.0
anaconda3-4.1.0
anaconda3-4.1.1
anaconda2 is Version 2 series and anaconda3 is Version 3 series. For the time being, let's put in the latest version of the 3 series. It takes a lot of time.
Terminal
$ pyenv install anaconda3-4.1.1
Do you want to add 2 systems just in case?
Terminal
$ pyenv install anaconda2-4.1.1
After installing Python, switch the version used by pyenv. You can check the installed Python version with the following command.
Terminal
$ pyenv versions
* system
anaconda2-4.1.1
anaconda3-4.1.1
I think it's a system now, so switch it to anaconda 3-4.1.1.
Terminal
$ pyenv global anaconda3-4.1.1
If you execute the python command and the following is displayed, Python installation is successful.
Terminal
$ python
Python 3.5.2 |Anaconda 4.1.1 (x86_64)| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
** NEXT ** → [Python] Road to snake charmer (2) Basics of Python
Recommended Posts