Now that you've purchased a new MacBook Air, here's what you need to do to build the same environment as your old MacBook Air. It feels like I'm writing it down for myself so I don't have to worry about re-setup, but I'm hoping that sharing it might be good for someone else.
Install in the following order.
Xcode
Launch the App Store and install Xcode.
Create and execute the following script.
pyenv_installer.sh
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'if [ -f ~/.bashrc ] ; then' >> ~/.bash_profile
echo '. ~/.bashrc' >> ~/.bash_profile
echo 'fi' >> ~/.bash_profile
source ~/.bashrc
pyenv install anaconda3-4.3.1
pyenv rehash
pyenv global anaconda3-4.3.1
echo 'export PATH="$PYENV_ROOT/versions/anaconda3-4.3.1/bin/:$PATH"' >> ~/.bashrc
source ~/.bashrc
XGBoost
Execute the following command.
python
conda install py-xgboost
Download the IPA font.
After downloading, create and execute the following script
jupyter_setup.sh
cd ~/Downloads
unzip IPAfont00303.zip
mv IPAfont00303/*.ttf ~/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf/
jupyter notebook --generate-config
echo "c.NotebookApp.notebook_dir = u'notebook'" >> ~/.jupyter/jupyter_notebook_config.py
autoconf、automake、libtool、CMake
Create the following script.
tools_installer.sh
cd ~/Downloads
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make && sudo make install
cd ~/Downloads
curl -fL http://ftpmirror.gnu.org/automake/automake-1.15.tar.gz | tar xzf -
cd automake-*
./configure --prefix=/usr/local
make && sudo make install
cd ~/Downloads
curl -fL http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz | tar xzf -
cd libtool-*
./configure --prefix=/usr/local
make && sudo make install
cd ~/Downloads
curl -OL https://cmake.org/files/v3.8/cmake-3.8.1-Darwin-x86_64.tar.gz
tar xzf cmake-3.8.1-Darwin-x86_64.tar.gz
cd cmame-*
cp CMake.app /Applications/
ln -s "/Applications/CMake.app/Contents/bin/ccmake" /usr/local/bin/ccmake
ln -s "/Applications/CMake.app/Contents/bin/cmake" /usr/local/bin/cmake
ln -s "/Applications/CMake.app/Contents/bin/cmake-gui" /usr/local/bin/cmake-gui
ln -s "/Applications/CMake.app/Contents/bin/cmakexbuild" /usr/local/bin/cmakexbuild
ln -s "/Applications/CMake.app/Contents/bin/cpack" /usr/local/bin/cpack
ln -s "/Applications/CMake.app/Contents/bin/ctest" /usr/local/bin/ctest
Execute with administrator privileges.
python
$ sudo sh tools_installer.sh
FFmpeg
Install FFmpeg to handle videos with OpenCV. It also installs pkg-config and yasm, which are required to install FFmpeg.
ffmpeg_installer.sh
cd ~/Downloads
curl -LO https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
tar xf pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2
./configure --with-internal-glib
make && make install
cd ~/Downloads
curl -LO http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install
cd ~/Downloads
curl -LO http://www.ffmpegmac.net/resources/ffmpeg-3.3.1.tar.bz2
tar xf ffmpeg-3.3.1.tar.bz2
cd ffmpeg-3.3.1
./configure
make && make install
Execute with administrator privileges.
python
$ sudo sh ffmpeg_installer.sh
OpenCV
Create the following script.
opencv_installer.sh
cd ~/Downloads
git clone https://github.com/Itseez/opencv.git opencv
git clone https://github.com/Itseez/opencv_contrib.git opencv_contrib
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_SHARED_LIBS=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D FFMPEG=ON \
-D PYTHON3_EXECUTABLE=/Users/[username]/.pyenv/versions/anaconda3-4.3.1/bin/python \
-D PYTHON3_INCLUDE_DIR=/Users/[username]/.pyenv/versions/anaconda3-4.3.1/include/python3.6m \
-D PYTHON3_LIBRARY=/Users/[username]/.pyenv/versions/anaconda3-4.3.1/lib/libpython3.6m.dylib \
-D PYTHON3_NUMPY_INCLUDE_DIRS=/Users/[username]/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/numpy/core/include \
-D PYTHON3_PACKAGES_PATH=/Users/[username]/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/Downloads/opencv_contrib/modules \
..
make -j4
make install
Execute with administrator privileges.
python
$ sudo sh opencv_installer.sh
TensorFlow
Execute the following command.
python
$ pip install tensorflow
Check if OpenCV and TensorFlow can be read. If there is no error, OK.
python
$ python
Python 3.6.0 |Anaconda 4.3.1 (x86_64)| (default, Dec 23 2016, 13:19:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> import tensorflow as tf
>>> exit()
$
It was done (^-^)
This will set up the operating environment for the code in the following article.
I also installed iRuby, which enables you to use Ruby with Jupyter Notebook. Create and execute the following script.
iruby_installer.sh
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export RBENV_ROOT="$HOME/.rbenv"' >> ~/.bashrc
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
rbenv install 2.4.1
rbenv rehash
rbenv global 2.4.1
gem install rbczmq
gem install iruby
gem install erector
iruby notebook
It was done (^-^)
In order for Safari to start automatically when jupyter notebook is started, add the following line to the configuration file.
python
c.NotebookApp.browser = u'/usr/bin/open -a Safari %s'
Recommended Posts