简体   繁体   English

python:“导入图像”仅在以root用户身份执行时有效

[英]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.

相关问题 通过anaconda提示符执行python代码时,导入numpy起作用,但通过cmd运行时产生错误 - Import numpy works when python code executed through anaconda prompt but produces an error when run through cmd PySpark 在终端中工作,但在 Python 代码中执行时不起作用 - PySpark works in terminal but not when executed in Python code Python 脚本在 IDLE 中执行时有效,但在控制台中无效 - Python script works when executed in IDLE, but not in console 在Python中,检查是否以root身份执行 - In Python, check if executed as root Ansible命令在root用户时起作用,但在默认用户时不起作用。 仅以默认用户身份抛出python PyYAML错误,但随后对root用户有效 - Ansible commands work when root, but not when default user. Throws a python PyYAML error only as default user, but then works for root TypeError 仅在 Linux 上执行时出现,在 Windows 上运行良好 - TypeError only appears when executed on Linux, works perfectly fine on Windows Selenium-Python-ChromeBrowser启动在python IDE中执行时有效,但从PyDev(Eclipse)执行时不起作用 - Selenium-Python-ChromeBrowser Launch works when executed in python IDE but it does not when executed from PyDev(Eclipse) python脚本可从命令行运行,但无法从Web应用程序执行时运行 - python script works from command line but not when it is executed from webapplication Grep perl regex 在终端中有效,但在从 python 执行时无效 - Grep perl regex works in terminal but not when executed from python python version check命令仅在用户模式下有效,而在root用户下无效 - python version check command works only in user mode and not root
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM