Python 如何在pypy沙盒中导入numpy

Python 如何在pypy沙盒中导入numpy,python,numpy,sandbox,pypy,Python,Numpy,Sandbox,Pypy,皮皮有一把叉子。如何在pypy沙盒中使用它 import numpyTraceback (most recent call last): File "<stdin>", line 1, in <module> File "/bin/lib_pypy/numpy/__init__.py", line 160, in <module> raise ImportError(msg) ImportError: Error importing numpy: you sh

皮皮有一把叉子。如何在pypy沙盒中使用它

import numpyTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/bin/lib_pypy/numpy/__init__.py", line 160, in <module>
raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
    its source directory; please exit the numpy source tree, and relaunch
    your python interpreter from there.
沙盒提示“没有名为numpy的模块”

然而,当我试图复制lib_pypypy目录中的numpy库时,我收到了这个错误消息。有没有办法在pypy沙盒中导入numpy

import numpyTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/bin/lib_pypy/numpy/__init__.py", line 160, in <module>
raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
    its source directory; please exit the numpy source tree, and relaunch
    your python interpreter from there.
import numpyTraceback(最后一次调用):
文件“”,第1行,在
文件“/bin/lib_pypy/numpy/_init_uuuu.py”,第160行,在
提高效率(msg)
ImportError:导入numpy时出错:不应尝试从导入numpy
其源目录;请退出numpy源代码树,然后重新启动
你的python解释器就在那里。

很抱歉,您根本无法在沙盒pypypy中导入numpy


几乎所有扩展模块都是这样。PyPy中的沙盒是一个很好的概念证明,在imho中确实安全,但它只是一个概念证明。这真的需要有人来做。在此之前,它只能用于“玩具”示例:几乎不导入任何内容的程序(或递归地仅导入纯Python模块)。

@yonexer首席开发人员的权威回答。常见问题解答中添加:是否有计划在未来恢复沙箱功能后允许模块导入()或者这在技术上根本不可能,也永远不可能?2019/08年的工作使沙箱功能更加强大,但仍然导入具有C-API兼容性的随机C扩展模块将永远不会安全工作。在某些假设的未来,numpy可能会被重写为其他格式,而不是大量的C(由pypy之外的人编写),这将为pypy中的沙箱(以及许多优化)打开大门。