2

Python (3.5) is not finding a file that is in a directory and I am trying to figure out where to put it. Here is the error I get:

Traceback (most recent call last):
  File "/home/rik/Pillow/faces.py", line 35, in <module>
    from PIL import Image
  File "/home/rik/Pillow/PIL/Image.py", line 67, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'

But I have a file called '_imaging.c' in the folder /home/rik/Pillow/ and I tried putting it in /home/rik/Pillow/PIL/ with no luck.

I tried to track where it is getting file via strace but I got an error:

rik@rik-MS-7971:~$ chmod +x /home/rik/Documents/tensorflow/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
rik@rik-MS-7971:~$ strace -f -e open /home/rik/Documents/tensorflow/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
strace: exec: Exec format error
Rik
  • 449
  • 2
  • 5
  • 12
  • 1
    Python won't import a `.c` file. How did you install PIL/Pillow? This is possibly a programming question rather than an Ubuntu question, and so may be considered off-topic. – Carl H Oct 04 '16 at 14:26
  • Not sure if it is a programming error but it seemed like an installation error. I believe I pip installed pillow. I thought you could import C objects the documentation seems to say that. Here is the comments from the function in the code: – Rik Oct 05 '16 at 02:55
  • # If the _imaging C module is not present, Pillow will not load. # Note that other modules should not refer to _imaging directly; # import Image and use the Image.core variable instead. # Also note that Image.core is not a publicly documented interface, # and should be considered private and subject to change. – Rik Oct 05 '16 at 02:55

1 Answers1

2

You mentioned in a comment below the original question that you installed Pillow with pip however you have Python 3.5 installed and pip3 install pillow is only supported for versions of Python <= Python 3.4.

Pillow is packaged as python-pil and python3-pil in all currently supported versions of Ubuntu, and it has replaced the discontinued PIL project in the default Ubuntu repositories since Ubuntu 13.04. You should uninstall pillow that you installed with pip and install python-pil and/or python3-pil instead.

karel
  • 110,292
  • 102
  • 269
  • 299