【出错笔记】Anaconda Sqlite3 ImportError: DLL load failed 问题解决

起因是我之前的Anaconda出了点问题,一气之下把它卸载了重新安装。结果输入 ipython 指令后意外发现报错:

$ ipython
D:\Anaconda\lib\site-packages\IPython\core\history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved
  warn("IPython History requires SQLite, your history will not be saved")
Python 3.7.2 (default, Jan  2 2019, 17:07:39) [MSC v.1915 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

抱着试一试的心态我尝试着 import sqlite3 看看,结果:

In [1]: import sqlite3                                                                  
----------------------------------------------------------------                        
ImportError                    Traceback (most recent call last)                        
<ipython-input-1-5239c6be4108> in <module>                                              
----> 1 import sqlite3                                                                  
                                                                                        
D:\Anaconda\lib\sqlite3\__init__.py in <module>                                         
     21 # 3. This notice may not be removed or altered from any source distribution.    
     22                                                                                 
---> 23 from sqlite3.dbapi2 import *                                                    
                                                                                        
D:\Anaconda\lib\sqlite3\dbapi2.py in <module>                                           
     25 import collections.abc                                                          
     26                                                                                 
---> 27 from _sqlite3 import *                                                          
     28                                                                                 
     29 paramstyle = "qmark"                                                            
                                                                                        
ImportError: DLL load failed: 找不到指定的模块。                                                 

一开始我尝试着 conda remove sqlite3 然后重新安装一下试试,结果发现由于这是一个基础库,一旦卸载了一大堆的库也得跟着卸载。

那就仔细分析一下呗,报错信息提示 DLL load failed 那肯定是dll出了问题。我按照对应的版本下了一个 Python 3.7.2 ,分别进入 Anaconda 和 Python 的DLLs目录,发现后者目录下有一个 sqlite3.dll 而前者没有,复制过去,搞定!

后记

后来我又看了一下,只是需要下载一个 sqlite3.dll 而已,没必要那么麻烦地把 python 再下载一遍,在Sqlite的官网就有dll的下载。找准那个 Precompiled Binaries for Windows 那一项就是的了。

猜你喜欢

转载自blog.csdn.net/frostime/article/details/86762858