cha*_*dog 16 python py2exe scipy
我使用python v2.7.3和scipy v0.11.0与py2exe v0.6.10在64位计算机上使用来自Christoph Gohlke的 64位版本的软件包得到以下错误消息.如果有人能提供相关和有用的建议,我将非常感激.这是错误消息:
Traceback (most recent call last):
File "test2.py", line 4, in <module>
File "scipy\sparse\__init__.pyo", line 191, in <module>
File "scipy\sparse\csgraph\__init__.pyo", line 146, in <module>
File "scipy\sparse\csgraph\_shortest_path.pyo", line 12, in <module>
File "scipy\sparse\csgraph\_shortest_path.pyo", line 10, in __load
File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path (scipy\sparse\csgraph\_shortest_path.c:14235)
ImportError: No module named _validation
Run Code Online (Sandbox Code Playgroud)
编译和运行可执行文件工作在旧的32位笔记本电脑(32位版本的所有东西),所以我想我可能不会包括我需要的一切.我新创建的test2.exe文件正确创建并显示相同的图形,如scipy的Getting Started页面所示.这是我的测试脚本:
# test2.py
# code is from the scipy web site example and works in Idle
from scipy import sparse
from scipy import optimize
from scipy import special
from numpy import *
from pylab import *
x = arange(0,10,0.01)
for k in arange(0.5,5.5):
y = special.jv(k,x)
plot(x,y)
f = lambda x: -special.jv(k,x)
x_max = optimize.fminbound(f,0,6)
plot([x_max], [special.jv(k,x_max)],'ro')
title('Different Bessel functions and their local maxima')
show()
Run Code Online (Sandbox Code Playgroud)
这是我的setup.py文件:
# setup.py
from distutils.core import setup
import py2exe
import os
import matplotlib
setup(
windows=[{'script': r'test2.py'}],
data_files = matplotlib.get_py2exe_datafiles(),
options = {
'py2exe': {
r'compressed': True,
r'optimize': 2,
r'includes': [
r'matplotlib',
r'matplotlib.backends.backend_tkagg',
r'matplotlib.pyplot',
#r'mpl_toolkits',
r'pytz'
],
r'dll_excludes': [r'MSVCP90.dll'],
r'excludes': [
'_gtkagg',
'_tkagg',
'_agg2',
'_cairo',
'_cocoaagg',
'_fltkagg',
'_gtk',
'_gtkcairo',
'tcl'
]
}
},
)
os.system("pause") # leaves the command prompt box open so I can read it
Run Code Online (Sandbox Code Playgroud)
test2.py和setup.py都驻留在c:\ python27 \中,我在64位计算机上得到了一个成功编译的test2.exe.在一个(可能)相关的注释中,我可以读到scipy v0.11.0引入了新的稀疏图形工具,我怀疑这是错误消息试图指向我的地方.我错过了我需要明确包含的内容吗?如果scipy有像matplotlib这样的get_py2exe_datafiles()函数来帮助正确捆绑东西,那就太好了.
提前感谢您提供的任何帮助,以及阅读这一点.
joa*_*uin 15
这似乎是常见的py2exe与SciPy的0.11.0 pyinstaller所讨论的问题在这里.
该线程中给出的时态解决方案是手动导入文件:
将以下代码添加到您的程序中
Run Code Online (Sandbox Code Playgroud)def dependencies_for_myprogram(): from scipy.sparse.csgraph import _validationpyInstaller和py2exe都解决了问题
您也可以尝试将此文件包含在"includes"中.py2exe应该足够了.
cha*_*dog 12
问题解决了!非常感谢joaquin.在搜索两天时,我没有遇到过pyinstaller链接.对于未来的读者,我添加了py2exe的选项
scipy.sparse.csgraph._validation
Run Code Online (Sandbox Code Playgroud)
到包括.
| 归档时间: |
|
| 查看次数: |
8724 次 |
| 最近记录: |