Martin Vegter
Martin Vegter

Reputation: 527

python: "import Image" only works when executed as root

when I start python interpreter as root, I can import 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:

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 ?

Upvotes: 1

Views: 215

Answers (1)

Hongyi Zhang
Hongyi Zhang

Reputation: 19

I guess you installed the Image package by using sudo pip install ... Please try to reinstall it without sudo.

Upvotes: 0

Related Questions