gpt4 book ai didi

python - pypy沙箱无法导入时间,导入站点失败

转载 作者:行者123 更新时间:2023-11-28 21:54:28 25 4
gpt4 key购买 nike

我运行了 rpython 翻译来创建一个 pypy 沙箱。

~/pypy-2.3.1-linux64/bin/pypy ../../rpython/bin/rpython -O2 --sandbox targetpypystandalone

有一些警告,其中两个似乎涉及时间。

[sandbox:WARNING] Not Implemented: sandboxing for external function 'clock_gettime'
[sandbox:WARNING] Not Implemented: sandboxing for external function 'clock_getres'

总而言之,当翻译完成时,当我运行沙箱时会出现以下输出:

'import site' failed
Python 2.7.6 (32f35069a16d819b58c1b6efb17c44e3e53397b2, Jun 11 2014, 19:06:04)
[PyPy 2.3.1 with GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>>

然后导入时间也失败了:

>>>> import time
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named time
>>>>

这是沙盒的预期行为吗?如果是这样,在沙盒进程中嵌入站点包等的正确做法是什么?我希望使用 pip 在那个环境中安装,但沙盒似乎让它变得非常困难。 (基本上,当我尝试安装 distribute.py 时,我遇到了导入时间问题,因为它需要需要时间的日期时间)

最佳答案

刚遇到同样的问题。解决方案是在构建 pypy-c 沙箱时包含 time 模块。在 these instructions ,构建时添加--withmod-time:

pypy ../../rpython/bin/rpython -O2 --sandbox targetpypystandalone --withmod-time

此处列出了其他可能的标志:http://pypy.readthedocs.org/en/latest/config/commandline.html

关于python - pypy沙箱无法导入时间,导入站点失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24172082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com