Hi,
I am running jupyter notebook within a python 3.9.12 conda environment.
I have a project with the following structure
project_folder
notebooks
notebook_A
....
module
__init__.py
tools
__init__.py
file.py
In the notebook, I try to import from module.tools.file import foo
and I constantly get a ModuleNotFoundError
.
But, when I try to do the import from a python terminal session or ipython everything works.
When I run import sys; print(sys.path)
in the notebook I obtain
['/Users/ff/dev/project_folder/notebooks',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python39.zip',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python3.9',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python3.9/lib-dynload',
'',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python3.9/site-packages']
and when I run the same in ipython I obtain
['',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python39.zip',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python3.9',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python3.9/lib-dynload',
'/opt/homebrew/Caskroom/miniforge/base/envs/envname/lib/python3.9/site-packages']
sys.executable
points to /opt/homebrew/Caskroom/miniforge/base/envs/envname/bin/python3.9
in the notebook and to /opt/homebrew/Caskroom/miniforge/base/envs/envname/bin/python
in ipython.
I am having the same issues with the imports when I run the notebook interface within VSCode (selecting the correct conda env) but not in PyCharm.
Has anybody experiencing the same issue or can anybody provide any help with this? I’ve been trying to follow most of the guides available, reinstall jupyter, etc but nothing seems to work.
Thanks!