You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am building a School Management system using Django==5.0.6. The architecture of the project is that I used a Tkinter GUI to build the interface to interact with the Django server, this interface enables users to use buttons to trigger starting and terminating the server. This Tkinter app is the entry script in my app.spec file. I'm using waitress to server.
The code runs perfectly well when I run it from the terminal but won't work once I compile it with Pyinstaller which makes me confused.
Here is my .spec script:
-- mode: python ; coding: utf-8 --
import os
import sys
import pkg_resources
from PyInstaller.utils.hooks import collect_all
import logging
with open(requirements_path) as f:
required_packages = [line.split('==')[0].replace('-', '_') for line in f.read().splitlines() if line and not line.startswith('#')]
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am building a School Management system using Django==5.0.6. The architecture of the project is that I used a Tkinter GUI to build the interface to interact with the Django server, this interface enables users to use buttons to trigger starting and terminating the server. This Tkinter app is the entry script in my app.spec file. I'm using waitress to server.
The code runs perfectly well when I run it from the terminal but won't work once I compile it with Pyinstaller which makes me confused.
Here is my .spec script:
-- mode: python ; coding: utf-8 --
import os
import sys
import pkg_resources
from PyInstaller.utils.hooks import collect_all
import logging
if getattr(sys, 'frozen', False):
log_file_path = os.path.join(sys._MEIPASS, 'spec_log.log')
else:
log_file_path = os.path.join(os.path.dirname(os.path.abspath(name)), 'spec_log.log')
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s', filename=log_file_path, filemode='a')
block_cipher = None
spec_file_dir = os.path.abspath('.')
requirements_path = os.path.join(spec_file_dir, 'requirements.txt')
with open(requirements_path) as f:
required_packages = [line.split('==')[0].replace('-', '_') for line in f.read().splitlines() if line and not line.startswith('#')]
customtkinter_datas, customtkinter_binaries, customtkinter_hiddenimports = collect_all('customtkinter')
installed_packages = [dist.project_name.replace('-', '_') for dist in pkg_resources.working_set]
logging.debug(f"Installed packages: {installed_packages}")
invalid_imports = ['pyinstaller_hooks_contrib']
valid_hiddenimports = [pkg for pkg in installed_packages if pkg not in invalid_imports]
logging.debug(f"Valid hidden imports: {valid_hiddenimports}")
datas = [
('cbt', 'cbt'),
('db.sqlite3', '.'),
('staticfiles/', 'staticfiles'),
('prominent/', 'prominent'),
('node_modules/', 'node_modules'),
('collectstatic/', 'collectstatic'),
('manage.py', '.'),
('migrate/', '.'),
('build_css/', '.'),
('migrations/', '.'),
('package.json', '.'),
('package-lock.json', '.'),
('run', '.'),
('tailwind.config.js', '.'),
('server_gui.py', '.'),
('pyinstaller_log.log', '.'),
('server_waitress_log.log', '.'),
('server_gui_log.log', '.'),
('start_waitress.py', '.'),
] + customtkinter_datas
hiddenimports = customtkinter_hiddenimports + required_packages + valid_hiddenimports + [
'altgraph', 'asgiref', 'certifi', 'charset_normalizer', 'contourpy',
'crispy_tailwind', 'cycler', 'darkdetect', 'django', 'django_crispy_forms',
'et_xmlfile', 'fonttools', 'idna', 'kiwisolver', 'lxml', 'matplotlib',
'numpy', 'openpyxl', 'packaging', 'pandas', 'pillow',
'pyparsing', 'python_dateutil', 'python_docx', 'pytz', 'requests', 'six',
'sqlparse', 'typing_extensions', 'tzdata', 'win32com',
'win32com.client', 'urllib3', 'whitenoise', 'XlsxWriter', 'waitress', 'whitenoise.middleware',
'customtkinter', 'portalocker', 'setuptools',
]
a = Analysis(
['server_gui.py'],
pathex=['.'],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=['.'],
runtime_hooks=['hooks/dorm_runtime_hook.py'],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='app',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False,
bundle_files=1
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name='app'
)
My server.gui script is long, I'll provide when requested.
What could be the problem?
Beta Was this translation helpful? Give feedback.
All reactions