I have a small problem, that is, I wrote a small program, and then got the several folders, a general folder outside, like this:
The Project
- the UI
-- controllerUi. Py
- the hardware
-- controller. Py
- the process
__main__. Py
Just set p y
I import the hardware of the controller in the controllerUi
the from.. The hardware import controller
Because I'm in the VS Code debugging, VS Code is Project is open the folder, and run all no problem, I look at startup is __main__ py files
Now I am writing a bat file to start the Project, so I set up a start on the outside of the Project. The bat,
Python -m Project
Appeared but can 't find the hardware problems, although I will start behind the bat to
CD Project
Python __main__. Py
It can perform, but I want to ask you, what is the right way, or python -m how do I use this command
CodePudding user response:
Suggest trying to use theimport sys
Sys. Path. Append (r 'absolute path to the hardwarew folder')
The import controller
Could be the result of a bat can't identify the relative path,

CodePudding user response:
Yes, I am __main__. Py in have add, so there is no question of execute this file directly, but the execution of python - m not
Sys. Path. Append ('.. ')