Ama*_*wal 5 python sqlite python-3.x
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'
Run Code Online (Sandbox Code Playgroud)
删除此错误我试图重新安装sqlite3
sudo apt-get install sqlite3
Run Code Online (Sandbox Code Playgroud)
但它说包已经存在.之后我试图安装它
pip3 install sqlite3
Run Code Online (Sandbox Code Playgroud)
但是再次安装时会出错
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
Run Code Online (Sandbox Code Playgroud)
但我的连接工作正常...现在我应该怎么做才能在python 3中导入sqlite3?
sqlite3是标准库的可选部分。它在您编译和安装 Python 3 时被编译,但sqlite3前提是正确的包含文件(开发头文件)可用。
如果您自己编译并安装了 Python 3,请安装依赖项(libsqlite3-dev或sqlite-devel或类似的,例如,取决于您的 Linux 发行版),然后重新编译并重新安装 Python 3。
在外部,库被维护为pysqlite;但该版本不支持 Python 3。即便如此,要安装它,您仍然需要那些sqlite开发文件,并且需要将其移植到 Python 3。您不妨重新编译 Python 3。
| 归档时间: |
|
| 查看次数: |
4456 次 |
| 最近记录: |