So I am doing a project where I have to create an installable Python package, install it on my desktop (Windows OS) and run the application contained in the folder. After packing and installing the code, I get 2 folders in the path where pip is installed:
project_pkg
project_pkg-0.0.1.dist-info
In the project_pkg folder I have 1 folder and 2 files:
__pycache__
__init__.py
project.py
What I want to do is run project.py via the cmd. How can I do it? The file init.py contains only this:
name = 'project'
UPDATE
After reading @Patrick Allen answer I figured out everything.Now I can run the application just by typing project [args]. When I do it the up runs as expected and the output is correct, but when it's about to finish, I get this weird error:
Traceback (most recent call last):
File "c:\...\appdata\local\programs\python\python37-
32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\...\appdata\local\programs\python\python37
-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\...\AppData\Local\Programs\Python\Python37-
32\Scripts\project.exe\__main__.py", line 9, in <module>
TypeError: 'module' object is not callable
The thing is that I am not using a __main__.py, plus when I try to look for the file specified by the last path, I cant find anything. Any ideas?
UPDATE 2
I figured a temporary solution, that uses the command sys.exit() when the application is done running. I dont know if it correct, but works for me.