i've been developing project in python time using pycharm. have no problem running in pycharm, want try , running command line (i'm using windows). when try run main file using python <filename>
within root directory, module not found error. pycharm doing/how can replicate it? also, pycharm creates pycache folders. if understanding correct compiling files, , makes runtime faster. since runtime long i'd same.
i'm using python 3.6
edit
file structure
-root\ ----scheduler\ ------main.py ------matrices ------models ------rhc ------singleton.py ------utils.py ------__init__.py ------apis\ acedb.py metrics.py __init__.py ------matrices\ distancematrix.py __init__.py ------models\ branch.py constants.py customer.py dispatch.py technician.py workorder.py __init__.py ------rhc\ pathfinder.py rhc.py schedule.py sched_time.py tech_schedule.py __init__.py
edit 2
found solution, had move main files outside of modules thanks!
if have below folder structure instance. add empty file named init.py , import app.py, in case have module1class , can import
from modules.module1 import module1class modules.module2 import module2class
folder structure
/app.py /modules /module1.py /module2.py /__init__.py
the first time rum app.py terminal python app.py, .pyc files created, leaving following folder structure
/app.py /modules /module1.py /module1.pyc /module2.py /module2.pyc /__init__.py
please refer python documentation it's documented on how create modules , importing them. i'm more used python2.7 , answer might not exact fit newer python versions.
https://docs.python.org/3/tutorial/modules.html
from there can learn more __ init __.py , module creation , exporting , importing
ps: use text editors develop in python, find pycharm bit on heavy side, cannot explain how pycharm works behind curtains.
Comments
Post a Comment