Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use pyinstaller with this template? #26

Closed
hellodword opened this issue Sep 8, 2023 · 0 comments
Closed

How to use pyinstaller with this template? #26

hellodword opened this issue Sep 8, 2023 · 0 comments

Comments

@hellodword
Copy link

git clone --depth=1 https://github.com/rochacbruno/fastapi-project-template
cd fastapi-project-template

# setup venv ...
python -V
# Python 3.11.4

pip install -r requirements.txt
python -m project_name run
# all ok

Try pyinstaller:

pip install pyinstaller
pyinstaller --name project_name -y --onefile project_name/__main__.py
./dist/project_name

Got:

Traceback (most recent call last):
  File "project_name/__main__.py", line 2, in <module>
    from .cli import cli
ImportError: attempted relative import with no known parent package
[455] Failed to execute script '__main__' due to unhandled exception!

It seems that this error can be solved with from project_name.cli import cli, but this is not a graceful solution I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant