LoginSignup
0
0

More than 5 years have passed since last update.

2018.12バージョンのAnaconda3環境で、Openpyxlが動かない(ImportError: You must install PIL to fetch image objects)

Last updated at Posted at 2019-01-08

【発生した問題】

最新版のAnaconda3(Version 2018.12 | Release Date: December 21, 2018)をインストールして、Openpyxlを使用したPythonスクリプトを走らせると、PIL関連エラーが出て動作しない。
pillowをpip installしたりしても、何も変わらない。他の環境では動いているので、スクリプトの問題ではない。

【解決策】

最新版Anaconda3ではなく、Anaconda3-5.1.0-Windows-x86_64.exeでインストールしたところ、問題解消した。

参考:【エラー内容詳細】
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\openpyxl\drawing\image.py", line 27, in _import_image
    import Image as PILImage
ModuleNotFoundError: No module named 'Image'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\openpyxl\drawing\image.py", line 29, in _import_image
    from PIL import Image as PILImage
  File "C:\Anaconda3\lib\site-packages\PIL\Image.py", line 60, in <module>
    from . import _imaging as core
ImportError: DLL load failed: 指定されたモジュールが見つかりません

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hosyoentyomitsumori.py", line 146, in <module>
    mitsumoribook = openpyxl.load_workbook('新品販売時保守契約見積テンプレート.xlsx', data_only=False)
  File "C:\Anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 338, in load_workbook
    reader.read()
  File "C:\Anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 301, in read
    self.read_worksheets()
  File "C:\Anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 276, in read_worksheets
    charts, images = find_images(self.archive, rel.target)
  File "C:\Anaconda3\lib\site-packages\openpyxl\reader\drawings.py", line 47, in find_images
    image = Image(BytesIO(archive.read(dep.target)))
  File "C:\Anaconda3\lib\site-packages\openpyxl\drawing\image.py", line 51, in __init__
    image = _import_image(img)
  File "C:\Anaconda3\lib\site-packages\openpyxl\drawing\image.py", line 31, in _import_image
    raise ImportError('You must install PIL to fetch image objects')
ImportError: You must install PIL to fetch image objects
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0