使用Python2.7和cx_Freeze创建可执行文件时,出现以下与Python.Runtime.dll相关的错误”

时间:2018-08-01 04:12:59

标签: python .net pyinstaller cx-freeze python.net

  

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

setup.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))

1 个答案:

答案 0 :(得分:0)

此行:

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

应为:

finder.IncludeFiles(dllname, dllname)

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