Matplotlib找不到已安装的PIL模块

g6baxovj  于 2023-11-22  发布在  其他
关注(0)|答案(1)|浏览(169)

我想打印rcParams来查看程序各阶段的设置。
以下是我的进口:

import matplotlib as mpl
from matplotlib import rcParams

字符串
我试过以下方法:
print(mpl.rcParamsDefault)print(mpl.rcParams)print(rcParams)
对于这三个,我得到了相同的错误消息:

Traceback (most recent call last):
  File "e:\Minitab_Killer\rcParams_print_out.py", line 1, in <module>
    import matplotlib as mpl
  File "C:\Users\D\miniconda3\lib\site-packages\matplotlib\__init__.py", line 107, in <module>
    from . import _api, cbook, docstring, rcsetup
  File "C:\Users\D\miniconda3\lib\site-packages\matplotlib\rcsetup.py", line 24, in <module>
    from matplotlib import _api, animation, cbook
  File "C:\Users\D\miniconda3\lib\site-packages\matplotlib\animation.py", line 34, in <module>
    from PIL import Image
  File "C:\Users\D\miniconda3\lib\site-packages\PIL\Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The specified module could not be found.


我发现了这个answer,有些人通过修复他们的pillow安装来解决这个问题。我正在使用anaconda,所以我运行conda install -c anaconda pillow命令,它更新了pillow,但错误消息没有改变。
我尝试了这个answer和运行pip install --force pillow,同样的错误消息。
当我尝试pip的答案时,我想要一个纯conda的解决方案。
conda list这里是相关的软件包:python 3.10.9pillow 9.4.0matplotlib 3.5.3
更新:
尝试thispip install --force pillowthisPillow 9.0.0,得到以下错误:

Traceback (most recent call last):
  File "e:\Minitab_Killer\rcParams_print_out.py", line 2, in <module>
    from matplotlib import rcParams 
  File "C:\Users\D\miniconda3\lib\site-packages\matplotlib\__init__.py", line 107, in <module>
    from . import _api, cbook, docstring, rcsetup
  File "C:\Users\D\miniconda3\lib\site-packages\matplotlib\rcsetup.py", line 24, in <module>
    from matplotlib import _api, animation, cbook
  File "C:\Users\D\miniconda3\lib\site-packages\matplotlib\animation.py", line 34, in <module>
    from PIL import Image
  File "C:\Users\D\miniconda3\lib\site-packages\PIL\Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The specified module could not be found.


接下来我应该尝试什么?

pinkon5k

pinkon5k1#

我在GitHub here上发布了一个bug报告。
事实证明这不是一个bug。Andrew Murray提供了多种方法来尝试解决问题,在我的情况下,conda upgrade conda解决了我的问题。

相关问题