测试 pysparse 时找不到 numpy._import_tools

Cannot find numpy._import_tools when testing pysparse

installing pysparse 与 Python 版本 2.7.15 之后:

$ pyenv local 2.7.15
$ pip install pysparse==1.2-dev213

我尝试测试 pysparse home page 中所示的安装。但是当我 运行 测试 testSuperlu.py,我收到以下错误:

Traceback (most recent call last):
  File "testSuperlu.py", line 3, in <module>
    from pysparse.tools import poisson
  File "/home/hakon/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pysparse/__init__.py", line 6, in <module>
    from numpy._import_tools import PackageLoader
ImportError: No module named _import_tools

好像 numpy._import_tools 不见了。我在用 numpy 版本 1.16.0.

编辑:

按照@wd15 在下面的回答中提出的建议,即安装不同版本的 pyparsenumpy:

$ pip install pysparse==1.1.1-dev
$ pip install numpy==1.15.1

然后运行再次测试程序testSuperlu.py:

$ python testSuperlu.py
ImportError: No module named _multiarray_umath
Traceback (most recent call last):
  File "testSuperlu.py", line 3, in <module>
    from pysparse.tools import poisson
  File "/home/hakon/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pysparse/__init__.py", line 9, in <module>
    from sparse import spmatrix
  File "/home/hakon/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pysparse/sparse/__init__.py", line 6, in <module>
    from pysparseMatrix import *
  File "/home/hakon/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pysparse/sparse/pysparseMatrix.py", line 57, in <module>
    from pysparse.sparse import spmatrix
ImportError: numpy.core.multiarray failed to import

FiPy 现在有一个 Nix recipe, which fixes the versions of PySparse and Numpy to be compatible. The Nix recipe uses version 1.1.1-dev of PySparse (hosted here) along with version 1.15.1 of Numpy (hosted here).

如果您不想使用 Nix 环境,那么我的建议是使用那些特定版本的 Numpy 和 PySparse 设置一个 Python 2 环境。