Python之ImportError: DLL load failed: 找不到指定的模块问题解决

版权声明:本文章是作者辛勤书写的成果,如需转载,请与作者联系,并保留作者信息以及原文链接,谢谢~~ https://blog.csdn.net/blueheart20/article/details/80985132

环境说明

Window 7, Python 3.6.5

问题描述

在基于python来进行import之时,报出如下的错误:

>> from PIL import Image
Traceback (most recent call last):
  File "<ipython-input-12-0f6709e38f49>", line 1, in <module>
    from PIL import Image

  File "d:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py", line 58, in <module>
    from . import _imaging as core

ImportError: DLL load failed: 找不到指定的模块。

有时候,也会报出类似的错误:

>> from PIL import Image
Traceback (most recent call last):

  File "<ipython-input-13-0f6709e38f49>", line 1, in <module>
    from PIL import Image

ImportError: cannot import name 'Image'

问题分析

这类问题一般都是在安装library之时,安全不完整,或者安装的library被覆盖或者破坏了,所以无法知道相应的类库。

问题解决

C:\Users\xxxx\>pip install Pillow
Requirement already satisfied: Pillow in d:\programdata\anaconda3\lib\site-packages (5.0.0)


C:\Users\xxxx>pip show Pillow
Name: Pillow
Version: 5.2.0
Summary: Python Imaging Library (Fork)
Home-page: http://python-pillow.org
Author: Alex Clark (Fork Author)
Author-email: aclark@aclark.net
License: Standard PIL License
Location: d:\programdata\anaconda3\lib\site-packages
Requires:
Required-by:

从上述指令中可以发现,该类库已经安装了。 但是由于其出了问题,所以需要重新安装。
首先卸载

pip uninstall Pillow

Uninstalling Pillow-5.0.0:
  Would remove:
    d:\programdata\anaconda3\lib\site-packages\pillow-5.0.0.dist-info\*
Proceed (y/n)? y
  Successfully uninstalled Pillow-5.0.0

然后重新安装:

pip install Pillow

Collecting Pillow
  Downloading https://files.pythonhosted.org/packages/1b/50/869910cd7110157fbefd0fed3db3656c1951f1bceecdd00e3716aa269609/Pillow-5.2.0-cp36-cp36m-win_amd64.whl (1.6MB)
    100% |████████████████████████████████| 1.6MB 69kB/s
Installing collected packages: Pillow
Successfully installed Pillow-5.2.0

验证

然后重新import Image即可发现一切正常了。

总结

如果其已经安装,但是无法找到的情况,大概率情况下是安装损坏,需要重新安装。

没有更多推荐了,返回首页