MacOSX 10.12.2 pyenv 20160629
If you get a ʻImport Error when trying to import a pip installed module, you have to make sure that
$ PYTHONPATH` is set correctly.
The installation destination of the module installed by pip is / usr / local / lib / python2.7 / site-packages /
, while the path when using pyenv is / Users / Hoge /. It is pyenv / shims / python / site-packages /
. No wonder this doesn't load modules installed with pip.
Python basically searches for the path inside the environment variable $ PYTHONPATH
.
Therefore, by adding the installation path set by this pip to $ PYTHONPATH
, it will be loaded normally.
$ export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages/
The rest is solved by adding the above script to .bashrc
and .zshrc
.
Recommended Posts