在使用 Python2.7 和 cx_Freeze 创建可执行文件时,我收到以下与 Python.Runtime 相关的错误.dll"



错误:[Erno 2]没有这样的文件或目录:'C:\Python27\lib\site packages\clr\Python.Runtime.dll

用于设置的代码.py

import sys
from cx_Freeze import setup, Executable
setup( name = "Severity_Insertion.py",
version = "2.7",
description = "Executable of serirty",
executables = [Executable("Severity_Insertion.py",base = "Win32GUI")]
)

hooks.py的代码,这与我的错误有关

def load_clr(finder, module):
"""the pythonnet package (imported as 'clr') needs Python.Runtime.dll
in runtime"""
module_dir = os.path.dirname(module.file)
dllname = 'Python.Runtime.dll'
finder.IncludeFiles(os.path.join(module_dir, dllname), dllname)

def load_sqlite3(finder, module):
"""In Windows, the sqlite3 module requires an additional dll sqlite3.dll to
be present in the build directory."""
if sys.platform == "win32":
dll_name = "sqlite3.dll"
dll_path = os.path.join(_get_base_prefix(), "DLLs", dll_name)
finder.IncludeFiles(dll_path, os.path.join("lib", dll_name))

此行:

finder.IncludeFiles(os.path.join(module_dir, dllname), dllname)

应该是:

finder.IncludeFiles(dllname, dllname)

因为pythonnet文件Python.Runtime.dllclr.pyd位于site-packages的正下方。

最新更新