[Python] Road to snake charmer (1) Environment construction

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.

Homebrew installation

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

Homebrew environment update

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.

Install pyenv

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.

Installation of Anaconda

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

Version switching

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

[Python] Road to snake charmer (1) Environment construction
[Python] Road to snake charmer (3) Python class
[Python] Road to a snake charmer (4) Tweak Numpy
[Python] Road to a snake charmer (6) Manipulate Pandas
[Python] Road to a snake charmer (5) Play with Matplotlib
Python environment construction
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
homebrew python environment construction
Python development environment construction
python2.7 development environment construction
Mac environment construction Python
Python environment construction @ Win7
From Python environment construction to virtual environment construction with anaconda
A road to intermediate Python
Python environment construction (Windows10 + Emacs)
CI environment construction ~ Python edition ~
Python environment construction For Mac
Anaconda3 python environment construction procedure
Python3 environment construction (for beginners)
Python environment construction and TensorFlow
Python development environment construction 2020 [From Python installation to poetry introduction]
Python environment construction under Windows7 environment
Procedure to exe python file from Ubunts environment construction
[MEMO] [Development environment construction] Python
Environment construction of python2 & 3 (OSX)
Environment construction of python and opencv
Get started with Python! ~ ① Environment construction ~
Anaconda python environment construction on Windows 10
Python + Unity Reinforcement learning environment construction
I checked Mac Python environment construction
Python environment construction memo on Mac
Python environment construction (pyenv, anaconda, tensorflow)
[Python3] Development environment construction << Windows edition >>
Python development environment construction on macOS
Python environment construction (pyenv + poetry + pipx)
Environment construction of python3.8 on mac
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
From Ubuntu 20.04 introduction to environment construction
Python3 TensorFlow for Mac environment construction
Emacs Python development environment construction memo
pytorch @ python3.8 environment construction with pipenv
[docker] python3.5 + numpy + matplotlib environment construction
Python3.6 environment construction (using Win environment Anaconda)
[Road to Intermediate] Understanding Python Properties
OpenCV3 & Python3 environment construction on Ubuntu
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
Change Python 64bit environment to 32bit environment with Anaconda
How to access environment variables in Python
[Road to intermediate Python] Use ternary operators
Method to build Python environment in Xcode 6
Python project environment construction procedure (for windows)
I want to build a Python environment
Steps to install Python environment on Ubuntu
How to prepare Python development environment [Mac]
Python3 + venv + VSCode + macOS development environment construction
VScode environment construction (Windows10, Python, C ++, C, Git)
To reference environment variables in Python in Blender