我正在使用cx_freeze
开发版本(建议here,也尝试了最新的稳定版1.3.1),我尝试从导入numpy和Enthought Canopy的文件构建Windows的可执行文件分配。这是文件test.py
:
import numpy as np
def f(x):
y = np.linspace(0,x,1000)
return y
if __name__ == '__main__':
print f(5)
这是setup.py文件:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = None
setup( name = "foo",
version = "0.1",
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [Executable("test.py", base=base)])
这是我在运行exe时遇到的错误:
Traceback (most recent call last):
File "C:\Users\Zah\AppData\Local\Enthought\Canopy32\User\lib\site-packages\cx_
freeze-4.3.1-py2.7-win32.egg\cx_Freeze\initscripts\Console.py", line 27, in <mod
ule>
exec code in m.__dict__
File "test.py", line 7, in <module>
File "C:\Users\Zah\AppData\Local\Enthought\Canopy32\User\lib\site-packages\num
py\__init__.py", line 143, in <module>
import add_newdocs
File "C:\Users\Zah\AppData\Local\Enthought\Canopy32\User\lib\site-packages\num
py\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Zah\AppData\Local\Enthought\Canopy32\User\lib\site-packages\num
py\lib\__init__.py", line 13, in <module>
from polynomial import *
File "C:\Users\Zah\AppData\Local\Enthought\Canopy32\User\lib\site-packages\num
py\lib\polynomial.py", line 17, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "C:\Users\Zah\AppData\Local\Enthought\Canopy32\User\lib\site-packages\num
py\linalg\__init__.py", line 48, in <module>
from linalg import *
File "C:\Users\Zah\AppData\Local\Enthought\Canopy32\User\lib\site-packages\num
py\linalg\linalg.py", line 23, in <module>
from numpy.linalg import lapack_lite
File "ExtensionLoader_numpy_linalg_lapack_lite.py", line 22, in <module>
File "ExtensionLoader_numpy_linalg_lapack_lite.py", line 14, in __bootstrap__
ImportError: DLL load failed: No se puede encontrar el m¾dulo especificado.
我注意到构建目录中有一个numpy.linalg.lapack_lite.pyd
文件。
答案 0 :(得分:0)
在Python安装目录中,转到Scripts目录(即C:/ Python27 / Scripts)。在此文件夹中,您应找到两个DLL文件:
编辑cxFreeze构建例程,以便将这两个文件复制到与可执行文件(构建目录)相同的目录中。在那之后,尝试运行exe,这应该解决问题(无论如何它都为我做了)。
我是怎么想出来的?你说你注意到了numpy.linalg.lapack_lite.p.yd文件。我所做的是使用名为DependencyWalker(website)的工具打开此文件。该程序分析文件具有的所有DLL依赖性。经过分析,它告诉我这两个DLL文件丢失了。
我真的希望这会有所帮助,我知道这些事情是多么令人沮丧!