ImportError: cannot import name '_imaging'

Bug #1993190 reported by Tina Russell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pillow (Ubuntu)
New
Undecided
Unassigned

Bug Description

If I try this:

tina@pannychis:~$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image

What I would expect to happen: Image class is imported

What happens instead:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 69, in <module>
    from . import _imaging as core
ImportError: cannot import name '_imaging'

I’m using version 7.0.0-4ubuntu0.5 on Ubuntu 20.04.5 LTS.

What I’ve read elsewhere is that accepted practice to get around this bug is to uninstall the apt version of Pillow and install it via pip instead, so I assume this means the apt package has fallen behind…? (Of course, I haven’t upgraded to Ubuntu 22.04.1 yet; is this bug fixed in that distro version’s version of the package?)

Revision history for this message
Tina Russell (tinarussell) wrote :

Okay, I’ve upgraded to Ubuntu 22.04.1, and the bug still happens, but it turns out it only happens with Python 3.6, and the only reason typing “python3” into the terminal brought me to Python 3.6 was because of a symlink, /usr/local/bin/python3, that was pointing directly to /usr/bin/python3.6. (First I tried using “sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1” to make Python 3.10 the default, thinking that was the problem, but when typing “python3” into the terminal still brought me to Python 3.6, I knew something was up.) Anyway, I’ve made a new /usr/local/bin/python3 symlink that just points to /usr/bin/python3 (which points to /etc/alternatives/python3, which now points to /usr/bin/python3.10), and now everything works fine.

tina@pannychis:~$ python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>>

Huh!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.