Can Not Freeze App (pyinstaller, cx_freeze)
See original GitHub issueSpecification
- Platform: Windows, Python
- Version: Win 10 [64bit], Py 3.6.x [32bit]
Description
First of all thank you for this package.
[Problem]
App runs great in python mode but gives errors in executable mode.
Executable gets generated but it does not run. Used pyinstaller
and cx_freeze
. Couldn’t use py2exe
because of Py 3.6. Spent a whole night but no joy.
Directory Structure:
/
db/
static/
templates/
main.py
server.py # i changed the static and template to be default rather than `gui`
setup.py
Below are the config and commands i used and errors.
cx_freeze
after making executable, when i run the .exe
i get this error. i pasted Python.runtime.dll
in to the lib folder in executable directory but no joy.
This is my setup.py
file for cx_freeze
import os, sys
from cx_Freeze import setup, Executable
base = None
include_files = [
"C:/Users/Ahmed Noor/AppData/Local/Programs/Python/Python36-32/Lib/site-packages/Python.Runtime.dll",
"./static", "./templates", "./db"
]
if sys.platform == "win32":
base = "Console"
setup(
name = "Institution_Name",
version = "0.1.0",
description = "Student_Record_System",
options = {
"build_exe" : {
'packages': ['encodings', 'asyncio', 'flask', 'cs50', 'sqlalchemy', 'jinja2', 'flask_compress', 'passlib', 'werkzeug', 'uuid', 'os', 'operator', 'win32gui', 'win32con', 'win32api', 'win32ui', 'ctypes',
'comtypes', 'webview', 'webbrowser'],
'excludes':['tkinter'],
"include_files" : include_files
}
},
executables = [Executable("main.py", base=base, targetName="Institution_Name.exe", icon="static/img/system/logo.ico")]
)
This is the Error I get when running .exe
,
INFO:werkzeug: * Running on http://127.0.0.1:5100/ (Press CTRL+C to quit)
INFO:werkzeug:127.0.0.1 - - [11/May/2018 22:00:01] "GET /check_if_app_is_running HTTP/1.1" 200 -
Traceback (most recent call last):
File "C:\Users\Ahmed Noor\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\Users\Ahmed Noor\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "main.py", line 42, in <module>
File "C:\Users\Ahmed Noor\AppData\Local\Programs\Python\Python36-32\lib\site-packages\webview\__init__.py", line 176, in create_window
_initialize_imports()
File "C:\Users\Ahmed Noor\AppData\Local\Programs\Python\Python36-32\lib\site-packages\webview\__init__.py", line 101, in _initialize_imports
import webview.winforms as gui
File "C:\Users\Ahmed Noor\AppData\Local\Programs\Python\Python36-32\lib\site-packages\webview\winforms.py", line 18, in <module>
import clr
SystemError: initialization of clr did not return an extension module
pyinstaller
When I make executable with pyinstaller, during the process WARNING Text keeps appearing something like WARNING: lib not found: api-ms-win-crt-<core, stdio, runtime etc.>-l1-1-0.dll dependency of <path/to/python.exe or path/to/python_dir/some_other_lib>
This is the command I use for pyinstaller,
pyinstaller main.py --hidden-import "clr" --name "SRS" --icon "static/img/system/logo.ico" --paths "static" --paths "templates" --paths "db" --path "server.py" --exclude-module "tkinter"
This is the problem I get when I run .exe
,
INFO:werkzeug: * Running on http://127.0.0.1:5100/ (Press CTRL+C to quit)
But no window opens. If i open the address on a web browser, it says
Internal Server Error
I end task
all .exe
instances from task manager and copy pasted the db, static, templates and server.py manually in the dist/<dist_dir> but got the following
INFO:werkzeug: * Running on http://127.0.0.1:5100/ (Press CTRL+C to quit)
INFO:werkzeug:127.0.0.1 - - [11/May/2018 23:27:31] "GET /check_if_app_is_running HTTP/1.1" 200 -
Traceback (most recent call last):
File "main.py", line 42, in <module>
File "site-packages\webview\__init__.py", line 176, in create_window
File "site-packages\webview\__init__.py", line 101, in _initialize_imports
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "c:\users\ahmed noor\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\webview\winforms.py", line 37, in <module>
File "site-packages\webview\util.py", line 144, in interop_dll_path
Exception: Cannot find WebBrowserInterop.dll
[10740] Failed to execute script main
Files
I will attach main.py
, server.py
and setup.py
with this thread in files.zip
. You can download the db/
, static/
and templates/
directories from the following github repo,
Github Repo: https://github.com/ahmednooor/SRS
.py
Files:
files.zip
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Got it working with
pyinstaller
using the following command,Feel free to close this issue. Thank you.
I have never managed to get the onefile option working too, but I think another user succeeded. This issue should be addressed though. Creating a pyinstaller hook would be the first step. I will create a new ticket.