This is a memo for building a development environment for reading the following books.
Book: Scraping & Machine Learning Development Techniques with Python http://www.socym.co.jp/book/1079
First of all, install the package manager "Homebrew" for Mac OS X. http://brew.sh/index_ja.html
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
On the way, enter the sudo password.
pyenv
Next, install the Python version manager "pyenv".
You can change the environment (installed packages) for each Python version.
$ brew install pyenv
Set environment variables.
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
$ echo 'eval "$(pyenv init -)"' >> ~/.profile
$ . ~/.profile
Check the versions and packages that can be installed using pyenv.
$ pyenv install --list
Install the latest Python 3.6.0 and anaconda 3-4.2.0.
$ pyenv install 3.6.0
$ pyenv install anaconda3-4.2.0
Check the installed version.
$ pyenv versions
Switch the version as follows. (Change global to local if you want to apply only to a specific directory)
(python3.6.Switch to 0)
$ pyenv global 3.6.0
$ pyenv rehash
$ python --version
Python 3.6.0
$ pyenv versions
system
* 3.6.0 (set by /Users/hisashi/.pyenv/version)
anaconda3-4.2.0
(anaconda3-4.2.Switch to 0)
$ pyenv global anaconda3-4.2.0
$ pyenv rehash
$ python --version
Python 3.5.2 :: Anaconda 4.2.0 (x86_64)
$ pyenv versions
system
3.6.0
* anaconda3-4.2.0 (set by /Users/hisashi/.pyenv/version)
Python package management is done with "pip". In addition, Anaconda package management is performed by "conda" and "pip".
I think Atom is a good editor. https://atom.io
It is a setting of scraping via a browser (Chapter 2, Section 2). We will use "anaconda 3-4.2.0" which is often used in machine learning.
$ pyenv global anaconda3-4.2.0
$ pyenv rehash
The book introduces the environment construction with Ubuntu + docker, but with MacOSX you can build the environment as follows.
$ brew install phantomjs
$ pip install selenium
$ pip install beautifulsoup4
I will continue to use "anaconda 3-4.2.0".
In the book, the following command is described, but an error occurs and it stops halfway.
$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py3-none-any.whl
You should add the "-I setuptools" option to avoid errors. http://datalove.hatenadiary.jp/entry/python/anaconda/install-tensorflow-into-anaconda-environment
$ pip install --upgrade -I setuptools https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py3-none-any.whl