lobe / lobe-python

Python toolset for working with Lobe models
MIT License
185 stars 38 forks source link

ImportError: cannot import name '_imaging' from 'PIL #22

Closed Pikamander2 closed 3 years ago

Pikamander2 commented 3 years ago

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.

image

Pikamander2 commented 3 years ago

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 3 years ago

Nevermind, I was trying to run it with IDLE instead of the command prompt, so it wasn't running in the virtual environment.