Make a note of what to check if you are having trouble running the module that you should have installed with pip.
Execution environment
This time the phenomenon
>>> from scipy.stats import multivariate_normal
Import Error: cannot import name multivariate_normal
I thought that the version of scipy was old, and even if I looked it up, it was the latest (0.16.1)
$ pip list | grep scipy
scipy (0.16.1)
Check module update with pip
update confirmation
$ pip install --upgrade scipy
Requirement already up-to-date: scipy in /usr/local/lib/python2.7/site-packages
Cleaning up...
Check module reference inside python
Reference confirmation
$ python -c 'import scipy; print scipy.__file__'
/Library/Python/2.7/site-packages/scipy/__init__.pyc
Is it different from the installation destination of pip?
$ ls /Library/Python/2.7/site-packages/site-packages | grep scipy
scipy
scipy-0.13.0-py2.7.egg-info
Confirm module reference path
$ python -c 'import sys; print sys.path'
['', '/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg', '/Library/Python/2.7/site-packages/Django-1.7.4-py2.7.egg', '/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/setuptools-8.2.1-py2.7.egg', '/usr/local/lib/python2.7/site-packages']
There are two site-packages in my python environment, and it seems that one site-packages is loaded with priority over the site-packages that is the installation destination with pip. And the cause was that I had installed the old scipy on the priority site-packages before I knew it. For the time being, delete the library not managed by pip and solve it. Speaking of which, when I created the Django environment, I didn't seem to have messed with the settings around here.
Recommended Posts