I have the following:
my_project/
hybrik/
__init__.py
models/
__init__.py
builder.py
scripts/
demo.py
And in demo.py:
from hybrik.models import builder
When I tried to run demo.py, an error occured:
ModuleNotFoundError: No module named 'hybrik'
I've already had __init__.py
, why can't it find the module?
Python will look for modules in locations on the PYTHONPATH
.
Assuming the actual code in those 4 Python files makes sense, you can do the following:
$env:pythonpath += ";/path/to/my_project"
set PYTHONPATH=%PYTHONPATH%;/path/to/my_project
PYTHONPATH=$PYTHONPATH:/path/to/my_project
Alternatively, you can build a package and install it in the environment of your script.
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.