1

I have been trying to implement pandas profiling in aws glue. One of the dependencies it uses is pillow. Since these are not there in aws glue by default I packaged them into a zip file and uploaded it. After that I ran the line

from pandas_profiling import ProfileReport

which gives the error ImportError: cannot import name '_imaging' from 'PIL' The complete stack trace is:

    File "/tmp/pandastest2", line 1, in <module>
        from pandas_profiling import ProfileReport
      File "/tmp/hope.zip/pandas_profiling/__init__.py", line 6, in <module>
        from pandas_profiling.controller import pandas_decorator
      File "/tmp/hope.zip/pandas_profiling/controller/pandas_decorator.py", line 4, in <module>
        from pandas_profiling.profile_report import ProfileReport
      File "/tmp/hope.zip/pandas_profiling/profile_report.py", line 15, in <module>
        from pandas_profiling.model.describe import describe as describe_df
      File "/tmp/hope.zip/pandas_profiling/model/describe.py", line 14, in <module>
        from pandas_profiling.model.summarizer import BaseSummarizer
      File "/tmp/hope.zip/pandas_profiling/model/summarizer.py", line 9, in <module>
        from pandas_profiling.model.summary_algorithms import (
      File "/tmp/hope.zip/pandas_profiling/model/summary_algorithms.py", line 11, in <module>
        from pandas_profiling.model.summary_helpers import (
      File "/tmp/hope.zip/pandas_profiling/model/summary_helpers.py", line 15, in <module>
        from pandas_profiling.model.summary_helpers_image import (
      File "/tmp/hope.zip/pandas_profiling/model/summary_helpers_image.py", line 5, in <module>
        import imagehash
      File "/tmp/hope.zip/imagehash.py", line 34, in <module>
        from PIL import Image, ImageFilter
      File "/tmp/hope.zip/PIL/Image.py", line 114, in <module>
        from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL'

So the specific problem is with the line from PIL import Image

I tried from PIL import ImageFilter and import PIL and both run without any error. So the only issue here is with the Image module.

This does not happen when I run it locally in my system. Is there someway to fix this issue and make it work in aws glue? When packaging the dependencies I made sure that the python version on my local system and aws glue were the same version namely python 3.7. I used Pillow version 8.2.3 and pip was the latest version.

Calvin Wilson
  • 31
  • 1
  • 5

0 Answers0