简体   繁体   中英

Run Python module from another directory

I'm running my Python module like this: python -m py_projects.my_module.my_submodule This is working pretty wel in case I'm in my PYthon project folder. But how can i run my module in case I'm not in my project folder. Was trying something like this:

python /home/pi/Desktop/Projects -m py_projects.my_module.my_submodule

But I got only error: no main module was found.

If you have your python file hello.py in Projects Directory

Simply Run:

python Desktop/Projects/hello.py

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