简体   繁体   中英

"No Module Named" error in Jupyter

A very similar problem , but different solution.

When I try to do import speech_recognition as sr in Jupyter, it returns the no moduled named... error.

But doing it in a terminal is fine. So I looked through the sys.paths of both. In Jupyter:

//anaconda/lib/python3.5/site-packages/six-1.10.0-py3.5.egg',
 '/Users/don',
 '/Users/don/Users/don/Documents/PyModules/skynet',
 '//anaconda/lib/python35.zip',
 '//anaconda/lib/python3.5',
 '//anaconda/lib/python3.5/plat-darwin',
 '//anaconda/lib/python3.5/lib-dynload',
 '/anaconda/lib/python3.5/site-packages/Sphinx-1.3.1-py3.5.egg',
 '//anaconda/lib/python3.5/site-packages',
 '//anaconda/lib/python3.5/site-packages/aeosa',
 '//anaconda/lib/python3.5/site-packages/IPython/extensions',
 '/Users/don/.ipython'

In terminal:

/Users/don/Applications/miniconda3/lib/python3.5/site-packages
/datashader-0.4.0-py3.5.egg
/Users/don
/Users/don/Users/don/Documents/PyModules/skynet
/Users/don/Applications/miniconda3/lib/python35.zip
/Users/don/Applications/miniconda3/lib/python3.5
/Users/don/Applications/miniconda3/lib/python3.5/plat-darwin
/Users/don/Applications/miniconda3/lib/python3.5/lib-dynload
/Users/don/Applications/miniconda3/lib/python3.5/site-packages
/Users/don/Applications/miniconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg

If I run this first in Jupyter, then the module speech_recognition imports fine: sys.path.append('/Users/don/Applications/miniconda3/lib/python3.5/site-packages')

I'd just like to know what's going on? I've found a solution of sorts, but I'd like a more elegant one, so I don't have to do sys.path.append every time. This is particularly endemic to a bunch of modules I've installed lately using pip install <module> .

This fixed it, but I don't know how or why. I just did $ pip3 install jupyter , and everything magically imported correctly after that. Nevertheless, if someone could give me a clue about what got fixed (because I don't even know what went wrong), that would be great.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM