[英]python: “import Image” only works when executed as root
when I start python interpreter as root, I can import Image: 当我以root身份启动python解释器时,可以导入Image:
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
>>> import Image
however, when I do the same as user ( www-data
), I get MemoryError
: 但是,当我与用户(
www-data
)相同时,出现MemoryError
:
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
>>> import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/PILcompat/Image.py", line 1, in <module>
from PIL.Image import *
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 57, in <module>
__import__("FixTk")
File "/usr/lib/python2.7/lib-tk/FixTk.py", line 15, in <module>
import ctypes
File "/usr/lib/python2.7/ctypes/__init__.py", line 552, in <module>
_reset_cache()
File "/usr/lib/python2.7/ctypes/__init__.py", line 276, in _reset_cache
CFUNCTYPE(c_int)(lambda: None)
MemoryError
Why is this happening ? 为什么会这样呢? How can I run a script as user
www-data
and use import Image
? 如何以用户
www-data
身份运行脚本并使用import Image
?
我猜您使用sudo pip install安装了Image软件包。请尝试不使用sudo重新安装它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.