为pypy安装了numpy但得到“ TypeError:只读属性'__module__'”

时间:2019-01-26 17:11:31

标签: python numpy pypy

我已经按照推荐的方式为PyPy 6.0安装了numpy:

./pypy -m ensurepip
./pip install -U pip wheel
./pypy -m pip install numpy

但是,这不起作用(在Ubuntu 16.04上):此安装成功,但是在尝试导入numpy时得到以下提示:

Python 2.7.13 (ab0b9caf307d, Apr 24 2018, 18:04:42)
[PyPy 6.0.0 with GCC 6.2.0 20160901] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jwimberl/src/pypy2-v6.0.0-linux64/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/home/jwimberl/src/pypy2-v6.0.0-linux64/site-packages/numpy/core/__init__.py", line 16, in <module>
    from . import multiarray
  File "/home/jwimberl/src/pypy2-v6.0.0-linux64/site-packages/numpy/core/multiarray.py", line 44, in <module>
    arange.__module__ = 'numpy'
TypeError: readonly attribute '__module__'

我还看到了关于pypy / numpy的其他问题,但它们都已经3岁以上了,我不确定它们是否是最新的。

1 个答案:

答案 0 :(得分:4)

numpy 1.16.0与pypy-v6.0 more details here之间不兼容。它将在下一个pypy版本中修复(即将推出),但与此同时,您可能应该改用numpy 1.15.4(例如,使用./pypy -m pip install 'numpy<1.16')。