3

我正在尝试使用 cx_Freeze 从 python 项目生成 .app 。通常我可以使用它,但是我的一些依赖于 scipy 的模块在执行时会出现导入错误:

No module named '_csr'

在构建文件夹下,我看到一个文件:

scipy.sparse.sparsetools._csr.so

并且观察 build 命令的输出似乎表明它正在复制 csr:

$ python3 setup.py bdist_mac | grep csr
m scipy.sparse.csr          /usr/local/lib/python3.3/site-packages/scipy/sparse/csr.py
m scipy.sparse.sparsetools._csr /usr/local/lib/python3.3/site-packages/scipy/sparse/sparsetools/_csr.so
m scipy.sparse.sparsetools.csr /usr/local/lib/python3.3/site-packages/scipy/sparse/sparsetools/csr.py
? _csr imported from scipy.sparse.sparsetools.csr
? os.path imported from NIF_WRF.util.StopPow, distutils.file_util, matplotlib.backends.backend_tkagg, matplotlib.cbook, numpy.core.memmap, numpy.distutils.command.scons, os, pkg_resources, pkgutil, scipy.lib.blas.scons_support, scipy.lib.blas.setup, scipy.lib.lapack.scons_support, scipy.linalg.setup, scipy.sparse.csgraph.setup, scipy.sparse.linalg.dsolve.setup, scipy.sparse.linalg.eigen.arpack.setup, scipy.sparse.linalg.isolve.setup, scipy.sparse.sparsetools.bsr, scipy.sparse.sparsetools.coo, scipy.sparse.sparsetools.csc, scipy.sparse.sparsetools.csgraph, scipy.sparse.sparsetools.csr, scipy.sparse.sparsetools.dia, scipy.special.setup, shutil, sysconfig
? scipy.lib.six.moves imported from scipy.integrate.quadrature, scipy.interpolate.interpolate, scipy.interpolate.polyint, scipy.linalg.special_matrices, scipy.misc.common, scipy.optimize.anneal, scipy.optimize.linesearch, scipy.optimize.nonlin, scipy.sparse.base, scipy.sparse.compressed, scipy.sparse.coo, scipy.sparse.csc, scipy.sparse.csr, scipy.sparse.dok, scipy.sparse.lil, scipy.sparse.linalg.eigen.lobpcg.lobpcg, scipy.sparse.linalg.isolve.lgmres, scipy.spatial.distance, scipy.special.basic, scipy.stats.stats
copying /usr/local/lib/python3.3/site-packages/scipy/sparse/sparsetools/_csr.so -> build/exe.macosx-10.8-x86_64-3.3/scipy.sparse.sparsetools._csr.so

该问题似乎与另一个问题有关,但该用户似乎通过再次构建来解决它,这在这里没有帮助。有任何想法吗?

更新

我在 .app 包内容中四处寻找,发现重命名scipy.sparse.sparsetools._csr.so解决_csr.so了该错误(尽管为另一个 scipy 组件生成了另一个类似的错误)。似乎 cx_Freeze 脚本没有正确命名 scipy 输入。

另外,这是我正在使用的版本:

  • cx_Freeze:4.3.2
  • scipy:0.13.0
  • 蟒蛇:3.3.2
4

0 回答 0