[英]cx_freeze keeps looking in python/libs, not in compiled libs
我cx_freeze
da Python程序(從cx_freeze 4.3.4遷移到5.0),我有一個問題,顯然cx_freeze一直在尋找Python(Anaconda)目錄中所需的庫,而不是在可執行文件的目錄中查找它產生的。
我正在獲得的當前錯誤如下,因為我正在使用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'
你在那里看到的目錄是我的Python安裝!!!! 為什么看那里? 現在在凍結的程序中,如果我去: myFrozenProgram/multiprocessing/
,我找到一個名為Process.pyc
的文件!
我的設置腳本如下。 它比平時稍微復雜一點,因為我在numpy中添加了自定義dll,因為過去發生了一個問題。 由於tcl錯誤,我添加了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])
事實證明,將Process.pyc
重命名為process.pyc
可以解決問題。 另一個具有相同問題的文件來自QtGui庫。 必須將文件QtGUI.pyd
重命名為QtGui.pyd
,然后一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.