【发布时间】:2017-10-15 02:07:27
【问题描述】:
在 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
所以是安装了还是没安装?有什么建议可以解决原来的问题吗?
【问题讨论】:
-
sqlite3 是一个可选模块在标准库中,它不是为你的平台编译的。你是如何安装 Python 的?如果您从源代码编译,则需要为要编译的模块提供 sqlite 开发头文件。
-
是否有页面描述检查我是否有标题,如何安装标题,如何以及在哪里编译 sqlite?
-
在 Redhat 上,我现在会寻找 libsqlite3-devel 包。
-
请看看我原来的问题:我已经试过了!它说:“无事可做”......
-
我确实问过你是如何安装 Python 的。
./configure脚本有一个--help选项,它详细说明了它要寻找的所有不同的东西,以及如何告诉它去别处寻找。如果您没有在标准位置的 SQLite 标头的机器上编译 Python,则永远不会编译_sqlite3C 模块,这就是我能告诉您的全部内容,所以我给出了标准响应。
标签: python-3.x sqlite redhat