sqlite3无法在python 3中导入

前端之家收集整理的这篇文章主要介绍了sqlite3无法在python 3中导入前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
sqlite与 python 2.7工作正常,但是当我尝试在python 3中导入它时,它会出错

> Traceback (most recent call last):   File "dbConnection.py",line 1,> in <module>
>     import sqlite3   File "/usr/local/lib/python3.4/sqlite3/__init__.py",line 23,in <module>
>     from sqlite3.dbapi2 import *   File "/usr/local/lib/python3.4/sqlite3/dbapi2.py",line 27,in <module>
>     from _sqlite3 import * ImportError: No module named '_sqlite3'

删除错误我试图重新安装sqlite3

sudo apt-get install sqlite3

但它说包已经存在.之后我试图安装它

pip3 install sqlite3

但是再次安装时会出错

Collecting sqlite3
 Retrying (Retry(total=4,connect=None,read=None,redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.',error('Tunnel connection Failed: 407 Proxy Authentication required',))': /simple/sqlite3/
 Retrying (Retry(total=3,))': /simple/sqlite3/
 Retrying (Retry(total=2,redirect=None)) after  connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb5ff3bc550>,'Connection to 196.1.114.80 timed out. (connect timeout=15)')': /simple/sqlite3/
 Retrying (Retry(total=1,))': /simple/sqlite3/
 Retrying (Retry(total=0,))': /simple/sqlite3/
 Could not find a version that satisfies the requirement sqlite3 (from versions: )
 No matching distribution found for sqlite3

但我的联系很好……
现在我应该怎么做才能在python 3中导入sqlite3?

解决方法

sqlite3是标准库的可选部分.它是在编译和安装Python 3时编译的,但前提是正确的sqlite3包含文件(开发头文件)可用.

如果您自己编译并安装了Python 3,请安装依赖项(例如libsqlite3-dev或sqlite-devel或类似的,具体取决于您的Linux发行版),然后重新编译并重新安装Python 3.

在外部,库保持为pysqlite;但是that release doesn’t support Python 3.即使这样,要安装它,你仍然需要那些sqlite开发文件,你需要将它移植到Python 3.你也可以重新编译Python 3.

猜你在找的Sqlite相关文章