简体   繁体   English

Jupyter 中的“No Module Named”错误

[英]"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.当我尝试在 Jupyter import speech_recognition as sr ,它返回no moduled named... moduled no moduled named...错误。

But doing it in a terminal is fine.但是在终端中这样做是可以的。 So I looked through the sys.paths of both.所以我查看了两者的 sys.paths 。 In Jupyter:在 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')如果我首先在 Jupyter 中运行它,那么模块speech_recognition导入: 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.我找到了各种各样的解决方案,但我想要一个更优雅的解决方案,所以我不必每次都执行sys.path.append This is particularly endemic to a bunch of modules I've installed lately using pip install <module> .这是我最近使用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.我只是做了$ pip3 install jupyter ,然后一切都神奇地正确导入了。 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.尽管如此,如果有人能给我一个关于修复了什么的线索(因为我什至不知道出了什么问题),那就太好了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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