1

My question is very similar to Why can't Python import Image from PIL? but a lot has changed in 5 years. I'm using python 3.7.3 and I'm also using pyenv. I would eventually like to use the interpreter pypy but I have to fix this problem first. I had pillow and PIL working back when I was not using pyenv and I was using 3.6 but not any more. Essentially when I run Python using Pycharm

from PIL import Image

I get:

Traceback (most recent call last):
  File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3267, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-4dba96fe377b>", line 1, in <module>
    from PIL import ImageColor
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/PIL/ImageColor.py", line 20, in <module>
    from . import Image
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/PIL/Image.py", line 56, in <module>
    from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/PIL/__init__.py)

When I run Python from Terminal I get

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/PIL/Image.py", line 56, in <module>
    from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/PIL/__init__.py)

If you look at the Image.py module at line 56 it says:

# should match _PyUnicodeUCS4_FromString and
        # _PyUnicodeUCS4_AsLatin1String
        warnings.warn(
            "The _imaging extension was built for Python with UCS4 support; "
            "recompile Pillow or build Python --with-wide-unicode. ",
            RuntimeWarning
            )
    # Fail here anyway. Don't let people run with a mostly broken Pillow.
    # see docs/porting.rst

I don't know what to do. Also I tried the solutions recommended here Why can't Python import Image from PIL? They were from 5 years ago, many of them geared toward Linux and did not work.

logic1976
  • 519
  • 1
  • 6
  • 19

1 Answers1

0

I eventually solved this by using miniconda3 installer. Someone else showed me how to install miniconda3 so unfortunately I cannot be of more help than this since he did it so fast that I've forgotten how he did it.

logic1976
  • 519
  • 1
  • 6
  • 19