使用带scipy的cx_Freeze时的ImportError

时间:2013-10-25 16:03:11

标签: python-3.x scipy cx-freeze

我正在尝试使用cx_Freeze从python项目生成.app。通常我有它工作,但我的一些依赖于scipy的模块在执行时有一个导入错误:

No module named '_csr'

在build文件夹下我看到一个文件:

scipy.sparse.sparsetools._csr.so

并观察构建命令的输出似乎表明它正在复制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

问题似乎与其他question有关,但该用户似乎通过再次构建来解决它,这在这里没有帮助。有什么想法吗?

更新

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

此外,以下是我正在使用的版本:

  • cx_Freeze:4.3.2
  • scipy:0.13.0
  • python:3.3.2

0 个答案:

没有答案