gpt4 book ai didi

python - sqlite3 无法在 python 3 中导入

转载 作者:IT王子 更新时间:2023-10-29 06:28:53 25 4
gpt4 key购买 nike

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, 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=2, connect=None, read=None, 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, 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=0, 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/
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 包含文件(开发 header )可用。

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

在外部,库维护为 pysqlite ;但是that release doesn't support Python 3 .即使那样,要安装它,您仍然需要那些 sqlite 开发文件,并且需要将它移植到 Python 3。您也可以重新编译 Python 3。

关于python - sqlite3 无法在 python 3 中导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41440749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com