DO NOT FORK, CLICK ON "Use this template" - A github template to start a Python Project - this uses github actions to generate your project based on the template.
However, when running directly __main__.py I get the following:
$ python ../python-project-template/project_name/__main__.py
Traceback (most recent call last):
File "C:\tmp\python-project-template\project_name\__main__.py", line 3, in <module>
from .cli import main # pragma: no cover
ImportError: attempted relative import with no known parent package
(venv)
Minor investigation
I noticed that if the corresponding line is changed to (removing the .)
from cli import main # pragma: no cover
The python command goes through:
$ python ../python-project-template/project_name/__main__.py
This will do something
However, in this case, the installed project_name stops working.
$ project_name
Traceback (most recent call last):
File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\tmp\venvs\venv\Scripts\project_name.exe\__main__.py", line 4, in <module>
File "c:\tmp\venvs\venv\lib\site-packages\project_name\__main__.py", line 3, in <module>
from cli import main # pragma: no cover
ModuleNotFoundError: No module named 'cli'
(venv)
All above observations hold irrespective of whether pip install ../python-project-template/ is run with the editable (-e) flag or not.
Desktop
Python 3.9.0
Microsoft Windows 11 Business, 10.0.22621 N/A Build 22621
Repro steps
git clone
the repository and thenThe
project_name
command works well.However, when running directly
__main__.py
I get the following:Minor investigation
I noticed that if the corresponding line is changed to (removing the
.
)The
python
command goes through:However, in this case, the installed
project_name
stops working.All above observations hold irrespective of whether
pip install ../python-project-template/
is run with the editable (-e
) flag or not.Desktop