Reputation: 63
I am using Python 3 on Windows 10 within a Jupyter notebook. I have two files in the same directory, Test1.py and Test2.py
In Test1 I have:
def method1():
print ("Hello World!")
And in Test2 I have:
from Test1 import method1
But when running Test2 I get the error:
No module named 'Test1'
I know this question has been asked before, so I tried the main suggestion: add the current directory to sys.path:
import sys
sys.path.append('/path/to/Test1')
However, this solution does not work for me and I still get the same error. Thank you for your help!
Upvotes: 1
Views: 534
Reputation: 100
I think you should put a __init__.py in your directory which have Test1.py and Test2.py.
Upvotes: 2