I°)App description
I made a program in python3. It's a program that work with a database in sql. I use the logiciel Py Charm community to do the application. I made a speciale folder with the command in python with all the sequence in sql in a folder Communicationddb Every GI (graphic interface) it's a class and each GI have it's own file. I use the following packages :
II°)problem
I use cx_freeze to freeze my programm. You can see the setup after this paragraph. What my problem ? When I freeze the programm and I run it (just after the freeze) I have a lot alert message telling me :
I can resolve the problem. I copy the folder in tkinter,ttkwidgets .... in the lib folder. I can resolve the probleme and the app work but I want to understand how to solve it.
Here the setup that work (when I said it work I need to add manually the folder)
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
icone = "icone_ip.ico"
options = {
'build_exe': {
'includes': ['atexit','reportlab','Communicationbdd']
}
}
executables = [
Executable('BouclePrincipale.py', base="Win32GUI",icon=icone)
]
setup(name='ALCOIP',
version='1.3',
author="Dr MARCUCCI Charles",
description='Outil de saisir des IP',
executables=executables
)
I try another code for the setup this one
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Python 3
"""
Icone sous Windows: il faut:
=> un xxx.ico pour integration dans le exe, avec "icon=xxx.ico"
=> un xxx.png pour integration avec PyQt4 + demander la recopie avec includefiles.
"""
import sys, os
from cx_Freeze import setup, Executable
#############################################################################
# preparation des options
# chemins de recherche des modules
# ajouter d'autres chemins (absolus) si necessaire: sys.path + ["chemin1", "chemin2"]
path = sys.path
# options d'inclusion/exclusion des modules
includes = ['atexit','reportlab','Communicationbdd'] # nommer les modules non trouves par cx_freeze
excludes = []
packages = [] # nommer les packages utilises
# copier les fichiers non-Python et/ou repertoires et leur contenu:
includefiles = []
if sys.platform == "win32":
base = 'Win32GUI'
# includefiles += [...] : ajouter les recopies specifiques à Windows
elif sys.platform == "linux2":
pass
# includefiles += [...] : ajouter les recopies specifiques à Linux
else:
pass
# includefiles += [...] : cas du Mac OSX non traite ici
# pour que les bibliotheques binaires de /usr/lib soient recopiees aussi sous Linux
binpathincludes = []
if sys.platform == "linux2":
binpathincludes += ["/usr/lib"]
# niveau d'optimisation pour la compilation en bytecodes
optimize = 0
# si True, n'affiche que les warning et les erreurs pendant le traitement cx_freeze
silent = True
# construction du dictionnaire des options
options = {
"includes": includes,
"excludes": excludes,
"packages": packages,
"include_files": includefiles
}
# pour inclure sous Windows les dll system de Windows necessaires
if sys.platform == "win32":
options["include_msvcr"] = True
#############################################################################
# preparation des cibles
base = None
if sys.platform == "win32":
base = "Win32GUI" # pour application graphique sous Windows
# base = "Console" # pour application en console sous Windows
icone = None
if sys.platform == "win32":
icone = "icone_ip.ico"
cible_1 = Executable(
Executable('BouclePrincipale.py', base="Win32GUI",icon=icone)
)
#############################################################################
# creation du setup
setup(
name="ALCOIp",
version="1.00",
description="Permet la saisi des IP",
author="Dr MARCUCCI Charles",
options={"build_exe": options},
executables=[cible_1]
)
and i Have this error message : p = os.fspath(p) Typeerror : expected str, bytes or os.PathLike object not Executable
I think it's link to py charm and how PyCharm work. I tried to remplace
includes = ['atexit','reportlab','Communicationbdd']
by
includes = ['atexit','venv/Lib/site-packages/reportlab','Communicationbdd']
but when I freeze the app can't run I have an error ModuleNotFoundError : No module named 'reportlab'
III°)The question
how to deal with this error ? Do I need to change of integrated development environment ?
Thank you for your future answers
I found the answer .... When I add a package it's only on PyCharm... I used pip to install on python and no just on PyCharm. I lunch again my build and it work like a charm