I cx_freeze
programme Python (déplacé de cx_freeze 4.3.4 à 5.0), et j'ai un problème que apparemment cx_freeze continue de chercher les libs dont il a besoin dans Python (Anaconda), au lieu de le chercher dans le répertoire de l'exécutable produit.cx_freeze continue à chercher dans python/libs, pas dans les bibliothèques compilées
L'erreur actuelle je reçois est le suivant, comme j'utilise multiprocessing
:
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "D:\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "Main.py", line 4, in <module>
File "D:\Anaconda3\lib\multiprocessing\__init__.py", line 16, in <module>
from . import context
File "D:\Anaconda3\lib\multiprocessing\context.py", line 5, in <module>
from . import process
ImportError: cannot import name 'process'
Le répertoire que vous voyez là est mon installation Python !!!! Pourquoi regarde-t-il là? Maintenant dans le programme gelé, si je vais à: myFrozenProgram/multiprocessing/
, je trouve un fichier appelé Process.pyc
!
Mon script de configuration est le suivant. C'est un peu plus compliqué que d'habitude parce que j'ajoute des DLL personnalisées à partir de numpy à cause d'un problème qui est arrivé dans le passé. Aussi la partie TCL j'ajouté en raison d'une erreur avec tcl:
import sys
import os
import json
import glob
from cx_Freeze import setup, Executable
from GUI.Meta import *
import os
PythonPath = os.path.split(sys.executable)[0] #get python path
os.environ['TCL_LIBRARY'] = os.path.join(PythonPath,"tcl","tcl8.6")
os.environ['TK_LIBRARY'] = os.path.join(PythonPath,"tcl","tk8.6")
mkl_files_json_file = glob.glob(os.path.join(PythonPath, "conda-meta","mkl-[!service]*.json"))[0] #json files that has mkl files list (exclude the "service" file)
with open(mkl_files_json_file) as file:
mkl_files_json_data = json.load(file)
numpy_mkl_dlls = mkl_files_json_data["files"] #get the list of files from the json data file
np_dlls_fullpath = list(map(lambda currPath: os.path.join(PythonPath,currPath),numpy_mkl_dlls)) #get the full path of these files
includefiles = [("GUI/icon.png","GUI/icon.png") + np_dlls_fullpath
target = Executable("Main.py",
#base = "Win32GUI",
icon = "GUI/icon.ico",
targetName="MyProg.exe")
setup(
name = "My program",
version = SOFTWARE_VERSION,
description = "Program",
options = {'build_exe': {'include_files':includefiles, 'includes': ["sip","re","atexit","PyQt5.QtCore","PyQt5.QtGUI","PyQt5.QtWidgets","multiprocessing"]}},
executables = [target])
Pour tous ceux qui veulent suivre ce numéro: https://bitbucket.org/anthony_tuininga/cx_freeze/issues/214/cx_freeze-keeps-looking-in-python-libs-not – TheONP