在 Redhat 4.4.7-18 上,我尝试使用 sqlite 运行 python3 代码,但出现以下导入错误:
Traceback (most recent call last):
File "database.py", line 7, in <module>
import sqlite3
File "/usr/local/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
我尝试安装它:
>sudo pip install sqlite3
Collecting sqlite3
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(101, 'Network is unreachable'))': /simple/sqlite3/
(当网络可达时…)并使用以下命令:
> sudo yum install sqlite-devel
Loaded plugins: post-transaction-actions, product-id, refresh-packagekit,
: rhnplugin, search-disabled-repos, security, subscription-manager
This system is receiving updates from RHN Classic or RHN Satellite.
Setting up Install Process
Package sqlite-devel-3.6.20-1.el6_7.2.x86_64 already installed and latest version
Nothing to do
所以是装的还是没装的?有什么建议可以解决原来的问题吗?
原文由 Alex 发布,翻译遵循 CC BY-SA 4.0 许可协议
不是直接的答案,但我最终用我的搜索引擎来到这里……所以对于我的网络冲浪者:
我有一个类似的问题,但是在 ubuntu 16.04 上手动编译 python3.6 版本:
我必须安装
libsqlite3-dev
(sudo apt install libsqlite3-dev
) 并从 python3.6 开始编译以使其工作。