[英]ImportError: No module named… on Jupyter Notebook using docker
I am running a project using docker on Windows 10 and Jupyter notebook (my apologies for not being precise with terms but I am quite new to all this). 我正在Windows 10和Jupyter笔记本上使用docker运行一个项目(很抱歉,我对术语不准确,但我对此不陌生)。 I have to import some modules that are stored locally on my PC but when I do so on Jupyter I get the error
ImportError: No module named
. 我必须导入一些本地存储在PC上的模块,但是当我在Jupyter上执行此操作时,出现错误
ImportError: No module named
。 I do not understand why some of the modules are loaded correctly and others are not. 我不明白为什么某些模块正确加载而其他模块却没有正确加载。 I checked my local folders on Windows and I saw that all of them have the empty
__init__.py
file. 我在Windows上检查了本地文件夹,发现它们都具有空的
__init__.py
文件。 Here is my code: 这是我的代码:
from abc.config import getConfig
from abc.log_util import getLogger
from abc.services.rcp.library import indb
The first two lines work properly, with the third one I get the ImportError
. 前两行正常工作,第三行我得到
ImportError
。 However, I do have some directories called abc/services/rcp/library
on my PC. 但是,我的PC上确实有一些名为
abc/services/rcp/library
目录。 If I run the command on the Jupyter notebook 如果我在Jupyter笔记本上运行命令
import sys
sys.path
I get the output 我得到了输出
['',
'/mnt/shared/abc-services-rcp',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/wx-3.0-gtk2',
'/usr/local/lib/python2.7/dist-packages/IPython/extensions',
'/root/.ipython']
so the abc-services-rcp
path seems to be there. 因此
abc-services-rcp
路径似乎在那里。 Any ideas what it could be? 有什么想法吗?
I solved the issue, I'll post the answer in case anyone has my same issue in the future. 我已解决了这个问题,如果将来有人遇到我同样的问题,我会发布答案。 Apparently the module
abc.services.rcp
was not installed. 显然未安装模块
abc.services.rcp
。 I found it out by executing the command pip list
and I saw that the module was not there. 我通过执行命令
pip list
发现了该错误,并且看到该模块不存在。 It was enough to execute on jupyter a pip install abc.services.rcp
and wait until the installation of the module was finished, then restart the kernel and run the import
code again. 足以在jupyter上执行
pip install abc.services.rcp
并等待模块安装完成,然后重新启动内核并再次运行import
代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.