I want to import the module from another directory scripts/driver/scheduler.py to run.py and execute it, but every time I get the following error msg
ModuleNotFoundError: No module named 'scripts'
I added empty init .py files, but it didn't solve the issue
Here are a tree and the code:
.
├── __init__.py
├── pythonmodules
│ ├── module
│ │ └── run.py
│ └── setup
│ └── smthelse
└── scripts
├── driver
│ ├── __init__.py
│ └── scheduler.py
└── resources
└── smthelse
run.py
import argparse
import os.path as op
from scripts.driver.scheduler import scheduler
some lines of code
s = scheduler()
scheduler.py
import re
import sys
class scheduler():
some code
if __name__ == '__main__':
s = scheduler()
Could somebody explain why it doesn't work?
Somehow pythonpath was missing. The following export fixed it: export PYTHONPATH=$PYTHONPATH:/home/user/myapp
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.