Build an environment for data analysis using python on Mac (El Capitan).
homebrew http://brew.sh/index_ja.html Install homebrew, a package management tool for mac.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
homebrew cask https://caskroom.github.io/
Since miniconda described later does not exist in homebrew, install homebrew cask.
$ brew tap caskroom/cask
miniconda http://conda.pydata.org/docs/
Install miniconda as a tool for managing your virtual environment.
$ brew cask install miniconda
Add the following description to .bash_profile etc. so that the installed miniconda will be in the PATH. Replace <user_name>
with any user.
~/.bash_profile
export PATH="/Users/<user_name>/miniconda3/bin:$PATH"
There seem to be various environment management tools for python, but so far conda alone is not inconvenient. If you know any inconvenience, please let me know.
Create a virtual environment for analysis with miniconda. It will be installed if you specify the required packages when creating the environment. Is it pandas, numpy, matplotlib, scikit-learn, jupyter, etc.? Basically, you can enter everything with anaconda.
$ conda create -n testenv python=3 anaconda
Switch to the virtual environment. (Environment name) is displayed at the beginning of the prompt.
$ source activate testenv
(testenv) $
When returning from the virtual environment to the original environment, it is as follows.
(testenv) $ source deactivate
$
conda If you want to add a package to your virtual environment, you can find it in conda and install it.
(testenv) $ conda search graphviz
Fetching package metadata .......
graphviz 2.38.0 2 defaults
2.38.0 3 defaults
2.38.0 4 defaults
(testenv) $ conda install graphviz
Even if you can't find it by searching, you can install it by specifying the channel if you search on Google and find it. When starting jupyter notebook, the warning "No module named'nbbrowserpdf'" appears, so try installing it.
(testenv) $ conda install --channel anaconda-nb-extensions nbbrowserpdf
pip If you still can't find it, or conda doesn't provide the version you want, you can also use pip to install the package in that virtual environment.
(testenv) $ pip install tansorflow
py3:~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.mathjax_url = 'https://cdn.mathjax.org/mathjax/latest/MathJax.js'
css:~/.jupyter/custom/custom.css
.CodeMirror pre, .output pre { font-family: "Source Han Code JP", monospace; }
$ conda install -c conda-forge jupyter_contrib_nbextensions
Recommended Posts