Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to import sqlite3 using Anaconda Python

I am trying to do the following in Python 3.7.1 on Windows

import sqlite3 

but I get the following error message

Traceback (most recent call last):   File "<console>", line 1, in <module>   File "c:\programdata\anaconda3\lib\sqlite3\__init__.py", line 23, in <module>     from sqlite3.dbapi2 import *   File "c:\programdata\anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>     from _sqlite3 import * ImportError: DLL load failed: The specified module could not be found. 

I have searched for a solution to the problem for quite a while now to no avail. I have also successfully run pip install pysqlite3 on the Anaconda prompt, but the import still fails. What do?

like image 354
G L Avatar asked Feb 25 '19 23:02

G L


People also ask

Do I need to pip install sqlite3?

You don't need to install sqlite3 module. It is included in the standard library (since Python 2.5).

Does Python install sqlite3?

Installation. SQLite3 can be integrated with Python using sqlite3 module, which was written by Gerhard Haring. It provides an SQL interface compliant with the DB-API 2.0 specification described by PEP 249. You do not need to install this module separately because it is shipped by default along with Python version 2.5.


1 Answers

I got this working on windows by downloading: the sqlite3 dll (find your system version)

And placing it into the folder: C:\Users\YOURUSER\Anaconda3\DLLs

(Depending on how you installed Anaconda, this may have to be placed into the following folder: C:\ProgramData\Anaconda3\DLLs)

According to @alireza-taghdisian, you can locate the exact path of your conda environments (where you need to copy the sqlite3 dll) by typing: conda info --envs on your anaconda prompt.

like image 195
elgsantos Avatar answered Oct 09 '22 17:10

elgsantos