Mac OS X El Capitan 10.11.3 MacBook Pro (Retina, 13-inch Early 2015)
HomeBrew is required, so install it if you don't have it
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
pyenv You can manage multiple versions of the Python environment and switch between them with commands.
$ brew install pyenv
Add the following to ~ / .profile
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
Check the current Python installation status (only the system is displayed before the environment is built)
$ pyenv versions
* system (set by /Users/yusuke/.pyenv/version)
List of installable Python versions (results only show where you think you need them)
$ pyenv install --list
2.7.11
...
3.5.1
...
anaconda3-2.4.0
...
Install the latest Python 3
$ pyenv install 3.5.1
If you get an error like this
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
Install command line tools
$ xcode-select --install
Reread the settings
$ . .profile
Reinstall
$ pyenv install 3.5.1
It seems better to rehash after installation
$ pyenv rehash
If you check the installed environment, it should look like this
$ pyenv versions
* system (set by /Users/yusuke/.pyenv/version)
3.5.1
Check by setting the default environment to 3.5.1.
$ pyenv global 3.5.1
$ pyenv versions
system
* 3.5.1 (set by /Users/yusuke/.pyenv/version)
anaconda A distribution that allows you to install Python and the Numerical Library at the same time, I will not use it this time, but I will install it because it is convenient. For Python3 series, select anaconda3, the latest version is 2.4.0, so install with the following command
$ pyenv install anaconda3-2.4.0
Rehash after installation
$ pyenv rehash
If you check the installed environment, it should look like this
$ pyenv versions
system
* 3.5.1 (set by /Users/yusuke/.pyenv/version)
anaconda3-2.4.0
virtualenv I will not use it this time. Whereas pyenv has an environment for each version, virtualenv allows you to switch between environments by giving a name to the environment (even with the same version of Python, you can keep it with a different name like python35hoge, python35fuga).
pyenv-virtualenv With pyenv, it was managed for each version, but you can name the pyenv environment, manage it more finely, and switch.
$ brew install pyenv-virtualenv
This time I want to create a TensorFlow environment with Python 3.5.1, so let's name it `` `py351tensorflow```. Installation and confirmation are as follows.
$ pyenv version
3.5.1 (set by /Users/yusuke/.pyenv/version)
$ pyenv virtualenv 3.5.1 py351tensorflow
$ pyenv rehash
$ pyenv versions
system
* 3.5.1 (set by /Users/yusuke/.pyenv/version)
3.5.1/envs/py351tensorflow
anaconda3-2.4.0
py351tensorflow
TensorFlow A machine learning library that Google made open source in November 2015. A lot of detailed explanations will come out if you google, so I will omit it here.
Click here for official documentation https://www.tensorflow.org/versions/master/get_started/os_setup.html
Use the py351tensorflow environment installed with pyenv-virtualenv earlier
$ pyenv global py351tensorflow
$ pyenv version
py351tensorflow (set by /Users/yusuke/.pyenv/version)
Install version 0.6.0 for Python 3
$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl
Successful installation
Successfully installed numpy-1.10.4 protobuf-3.0.0a3 setuptools-19.6 six-1.10.0 tensorflow-0.6.0 wheel-0.26.0
Confirmed operation according to the official document
$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
I tensorflow/core/common_runtime/local_device.cc:40] Local device intra op parallelism threads: 4
I tensorflow/core/common_runtime/direct_session.cc:58] Direct session inter op parallelism threads: 4
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>> quit()
If this is the case, the installation is successful.
Recommended Posts