简体   繁体   中英

Python Pycharm module path

I would understand this behaviour.

In Pycharm I can successfully run (green play button) this main.py which includes src.v0.Det.py

src
|
+--v0
|   |
|   +--Det.py  (class det)
|      __init__.py
|
+-- main.py
    __init__.py

main.py
------------
from src.v0.Det import det
....

But when I run on unix using: python main.py I get "No module named src.v0.Det".

I can obviously remove "src" and it works but I don't want to change the file. How can I run this file like in Pycharm?

Riccardo

export PYTHONPATH="${PYTHONPATH}:<.....path.to.src.without.src....>"

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM