1

我一直在尝试在 aws 胶水中实现熊猫分析。它使用的依赖项之一是枕头。由于这些默认情况下在 aws 胶水中不存在,因此我将它们打包成一个 zip 文件并上传。之后我跑了线

from pandas_profiling import ProfileReport

这给出了错误 ImportError: cannot import name '_imaging' from 'PIL' 完整的堆栈跟踪是:

    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'

所以具体问题出在线路上from PIL import Image

我试过from PIL import ImageFilter并且import PIL都运行没有任何错误。所以这里唯一的问题是图像模块。

当我在系统中本地运行它时,不会发生这种情况。有没有办法解决这个问题并让它在 aws 胶水中工作?在打包依赖项时,我确保本地系统上的 python 版本和 aws 胶水是相同的版本,即 python 3.7。我使用了 Pillow 版本 8.2.3,而 pip 是最新版本。

4

0 回答 0