Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

【発生した問題】

最新版の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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away