简体   繁体   中英

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). 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 . 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. 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 . However, I do have some directories called abc/services/rcp/library on my PC. If I run the command on the Jupyter notebook

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. 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. I found it out by executing the command pip list and I saw that the module was not there. 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.

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