Python下ImportError: DLL load failed

				版权声明:本文章是作者辛勤书写的成果,如需转载,请与作者联系,并保留作者信息以及原文链接,谢谢~~					https://blog.csdn.net/blueheart20/article/details/79612985				</div>
							            <div id="content_views" class="markdown_views">
						<!-- flowchart 箭头图标 勿删 -->
						<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path></svg>
						<p></p><div class="toc"><div class="toc">

环境依赖

OS: window 7, python 3.6 Anaconda: 5.0.1

问题的提出

在运行Python代码的时候,碰到了如下问题:

runfile('D:/code/test.py', wdir='D:/code')
Traceback (most recent call last):

  File "<ipython-input-4-f0247c595423>", line 1, in <module>
    runfile('D:/code/test.py', wdir='D:/code')

  File "d:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "d:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/BaiduNetdiskDownload/第十周/程序/10-3-验证码识别.py", line 8, in <module>
    from PIL import Image

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

ImportError: DLL load failed: 找不到指定的模块
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

经过检查Pillow都已经安装,且版本为4.2.1 [pillow: 4.2.1-py36hdb25ab2_0]。
感觉问题是Pillow或者Pillow的依赖库的安装不完整造成的,因为dll没有找到。

问题的查找

查找了一番资料之后,找到了一个解决方案:

  • conda uninstall pillow
  • conda update pip
  • pip install pillow
    从上述指令分析可知,conda中pillow的版本估计比较老或者有问题,需要使用pip库中的pillow包,且需要安装其最新版本的包。
    基本的操作如下:

关闭anaconda,执行指令conda uninstall pillow

指令输出结果信息:

Solving environment: done
==> WARNING: A newer version of conda exists. <==
  current version: 4.4.6
  latest version: 4.4.11

Please update conda by running
    $ conda update -n base conda

-- Package Plan --

  environment location: D:\ProgramData\Anaconda3

  removed specs:
    - pillow


The following packages will be REMOVED:

    anaconda-navigator: 1.6.12-py36hdad2993_0
    pillow:             4.2.1-py36hdb25ab2_0
    scikit-image:       0.13.0-py36h6dffa3f_1

Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: \ DEBUG menuinst_win32:__init__(185): Menu: name: 'Anaconda${PY_VER} ${PLATFORM}', prefix: 'D:\ProgramData\Anaconda3', env_name: 'None', mode: 'None', used_mode: 'system'
DEBUG menuinst_win32:create(299): Shortcut cmd is D:\ProgramData\Anaconda3\pythonw.exe, args are ['D:\\ProgramData\\Anaconda3\\cwp.py', 'D:\\ProgramData\\Anaconda3', 'D:\\ProgramData\\Anaconda3\\pythonw.exe', 'D:\\ProgramData\\Anaconda3\\Scripts\\anaconda-navigator-script.py']
done
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

conda update pip # 升级 pip

指令升级内容输出如下:

Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.6
  latest version: 4.4.11

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: D:\ProgramData\Anaconda3

  added / updated specs:
    - pip


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pip-9.0.1                  |           py36_5         2.5 MB

The following packages will be UPDATED:

    pip: 9.0.1-py36hadba87b_3 --> 9.0.1-py36_5

Proceed ([y]/n)? y


Downloading and Extracting Packages
pip 9.0.1: ######################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  1. pip install pillow
    指令升级输出内容如下:
Collecting pillow
  Using cached Pillow-5.0.0-cp36-cp36m-win_amd64.whl
Installing collected packages: pillow
Successfully installed pillow-5.0.0
You are using pip version 9.0.1, however version 9.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

由上文可知,pillow的版本从4.2.1 升级到了5.0.0的版本。

问题的解决

重新执行一下程序,dll找不到的问题已经被修复了。

接着把之前卸载的anaconda-navigator安装一下:

conda install anaconda-navigator

结果输出信息如下:

Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.6
  latest version: 4.4.11

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: D:\ProgramData\Anaconda3

  added / updated specs:
    - anaconda-navigator


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    anaconda-navigator-1.7.0   |           py36_0         4.3 MB
    pillow-5.0.0               |   py36h0738816_0         624 KB
    ------------------------------------------------------------
                                           Total:         4.9 MB

The following NEW packages will be INSTALLED:

    anaconda-navigator: 1.7.0-py36_0
    pillow:             5.0.0-py36h0738816_0

Proceed ([y]/n)? y


Downloading and Extracting Packages
anaconda-navigator 1.7.0: ########################################################################################################################################################## | 100%
pillow 5.0.0: ###################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: \ DEBUG menuinst_win32:__init__(185): Menu: name: 'Anaconda${PY_VER} ${PLATFORM}', prefix: 'D:\ProgramData\Anaconda3', env_name: 'None', mode: 'None', used_mode: 'system'
DEBUG menuinst_win32:create(299): Shortcut cmd is D:\ProgramData\Anaconda3\pythonw.exe, args are ['D:\\ProgramData\\Anaconda3\\cwp.py', 'D:\\ProgramData\\Anaconda3', 'D:\\ProgramData\\Anaconda3\\pythonw.exe', 'D:\\ProgramData\\Anaconda3\\Scripts\\anaconda-navigator-script.py']
done
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

然后就重新可以打开Anaconda的界面了。

总结

这种问题比较难以侦测和修复,主要无法感知其具体的问题根源,默认可以升级至最新版本。

参考资料

  1. http://blog.csdn.net/m0_37422289/article/details/79284541
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值