Reputation: 9655
I have downloaded a package with the following general structure:
- pkg
- runs
- __init__.py
- script.py
- data
- subdata
- __init__.py
- datascript.py
When I try to run script.py
from the Anaconda prompt using
C:\pkg>python runs/script.py
I get the error
Traceback (most recent call last):
File "runs/script.py", line 4, in <module>
from data.subdata import *
ModuleNotFoundError: No module named 'data.subdata'
so apparently, python is interpreting data.subdata
as a module instead of a path.
How can I fix that?
Upvotes: 1
Views: 1696
Reputation: 4440
add the path in sys.path ->sys.path.append('path_to_module')
read more :
https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html
Upvotes: 1