Python 带py2exe的scipy

Python 带py2exe的scipy,python,scipy,py2exe,Python,Scipy,Py2exe,我使用PythonV2.7.3和scipy v0.11.0以及py2exe v0.6.10在64位机器上获得以下错误消息,该机器使用来自的64位版本的软件包。如果有人能提供相关和有用的建议,我将不胜感激。以下是错误消息: Traceback (most recent call last): File "test2.py", line 4, in <module> File "scipy\sparse\__init__.pyo", line 191, in <module

我使用PythonV2.7.3和scipy v0.11.0以及py2exe v0.6.10在64位机器上获得以下错误消息,该机器使用来自的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
这是我的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
test2.py和setup.py都位于c:\python27\中,我在64位机器上成功地编译了test2.exe。在一个(可能)相关的注释中,我可以看到scipy v0.11.0引入了新的稀疏图形工具,我怀疑这就是错误消息试图指向我的地方。我是否遗漏了需要明确包含的内容?如果scipy有一个像matplotlib这样的get_py2exe_datafiles()函数来帮助正确绑定,那就太好了


提前感谢您提供的任何帮助,并感谢您阅读本文。

如前所述,这似乎是py2exe和使用scipy 0.11.0的pyinstaller的常见问题

该线程中给出的临时解决方案是手动导入文件:

将以下代码添加到程序中

def dependencies_for_myprogram():
    from scipy.sparse.csgraph import _validation
pyInstaller和py2exe的问题都已解决


您也可以尝试使用“includes”包含此文件。py2exe获得它应该足够了

问题解决了!非常感谢你,华金。在两天的搜索中,我没有发现pyinstaller链接。对于未来的读者,我在py2exe的选项中添加了

scipy.sparse.csgraph._validation

到包含项。

bundle\u files=3也没有帮助
scipy.sparse.csgraph._validation