Reputation: 107
I want to import a user-defined module utils.py
in Jupyter Notebook. This should be a trivial task, but for some reason it fails.
Project structure:
myapp/data/test.csv
myapp/packages/utils.py
myapp/test.ipynb
The file utils.py
contains many functions, e.g. def myfunc():...
.
In test.ipynb
I tried from packages import utils
. Also I tried to put utils.py
into the same folder as test.ipynb
and run import utils
. But all the time it fails with one of these two errors:
ImportError: cannot import name 'utils' ModuleNotFoundError: No module named 'utils'
The command sys.executable
executed from the notebook gives me a correct path to python.exe.
It's weird because I can import data without any issues as follows:
df = pd.read_csv("data/test.csv", sep=";")
How can I check what causes this problem?
Upvotes: 0
Views: 2173
Reputation: 106
Try this:
from packages.utils import *
It worked for me, so I hope it works for you aswell.
Upvotes: 1