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
PyInstaller not found #2549
Comments
Thanks for reporting this issue @hrauch! Can anyone with Windows 11 reproduce the problem? Should we simply add |
Not able to reproduce the problem. |
If you use a virtual environment, it says that the package is not found. Try installing and packaging pyinstall without a virtual environment. |
Been able to reproduce that on Windows 10 running a Python 3.12.2 virtual envronment and to find a working solution. My multiplatform build script looks like this (Linux can be added as well): from pathlib import Path
import subprocess
import platform
import os
import shutil
import nicegui
APP_NAME = 'Your App Name'
def remove(folder):
if os.path.exists(folder):
shutil.rmtree(folder)
def build_windows():
return [
'pyinstaller',
'main.py', # your main file with ui.run()
'--name', APP_NAME, # name of your app
'--onedir',
'--windowed',
'--icon', 'AppIcon.ico'
]
def build_macos():
return [
'python',
'-m', 'PyInstaller',
'main.py', # your main file with ui.run()
'--name', APP_NAME, # name of your app
'--windowed',
'--icon', 'AppIcon.icns'
]
build_matrix = {
'Windows': build_windows,
'Darwin': build_macos
}
common_data_params = [
'--add-data', f'{Path(nicegui.__file__).parent}{os.pathsep}nicegui',
# '--add-data', f'assets{os.pathsep}assets' # you can add your own additional resources
]
if __name__ == "__main__":
platform_name = platform.system()
if platform_name not in build_matrix:
print(f'Unsupported platform {platform_name}')
sys.exit(1)
remove('build')
remove('dist')
subprocess.call(build_matrix[platform_name]() + common_data_params) |
Thanks @gotev! |
@falkoschindler I agree and I volunteer for a PR, just tell me where do we want to have this added. Have to test it on a Linux btw to have a complete script. |
@gotev That would be awesome! I think we can start by putting it in the root directory of the repository. Once we have a release candidate, I'd love to make the executable available as an official script in the NiceGUI package. We probably just need to add something like this to pyproject.toml: [tool.poetry.scripts]
your-command = "your_project_name.your_script:main" |
* feat: added build package script * code review and refactoring * fix data path * always print the PyInstaller command * fix add-data format * add more description and help text --------- Co-authored-by: Falko Schindler <falko@zauberzeug.com>
Description
I installed nicegui, pyinstaller and pywebview in a virtual environment with Python 3.12 and Windows 11.
Trying your example on https://nicegui.io/documentation/section_configuration_deployment I get this error message:
C:\Program Files\Python312\python.exe: No module named PyInstaller
If I change the last line of your build.py script in
subprocess.call(cmd, shell=True)
everything is ok. May be that this modification is only needed with Windows 11.
The text was updated successfully, but these errors were encountered: