ImportError: cannot import name '_imaging' from 'PIL
Pikamander2 opened this issue · 2 comments
Pikamander2 commented
When running the example script on Windows 10 in a Python 3.8 virtual environment, I get this error:
Traceback (most recent call last):
File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\lobe-test-1.py", line 1, in <module>
from lobe import ImageModel
File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\lobe\__init__.py", line 2, in <module>
from .model.image_model import ImageModel
File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\lobe\model\image_model.py", line 4, in <module>
from PIL import Image
File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\PIL\Image.py", line 94, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\PIL\__init__.py)
Googling the error returns this Stack Overflow page, which suggests that PIL and Pillow are conflicting with each other.
Pikamander2 commented
I assume that this is the problem:
Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead.
How can that be fixed?
Pikamander2 commented
Nevermind, I was trying to run it with IDLE instead of the command prompt, so it wasn't running in the virtual environment.