问题描述
sqlite3 模块包含在 Python 2.5+ 版本中.但是,我坚持使用 2.4 版.我上传了 sqlite3 模块文件,将目录添加到 sys.path,但是当我尝试导入它时出现以下错误:
The sqlite3 module is included in Python version 2.5+. However, I am stuck with version 2.4. I uploaded the sqlite3 module files, added the directory to sys.path, but I get the following error when I try to import it:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "sqlite3/__init__.py", line 23, in ?
from dbapi2 import *
File "sqlite3/dbapi2.py", line 26, in ?
from _sqlite3 import *
ImportError: No module named _sqlite3
文件_sqlite3"在 lib-dynload 中,但如果我将其包含在 sqlite3 目录中,则会出现其他错误.
The file '_sqlite3' is in lib-dynload, but if I include this in the sqlite3 directory, I get additional errors.
有什么建议吗?我在有限的环境中工作;我无权访问 GCC 等.
Any suggestions? I am working in a limited environment; I don't have access to GCC, among other things.
推荐答案
我在 CentOS 和 python 2.4 上遇到了同样的问题
I had same problem with CentOS and python 2.4
我的解决方案:
yum install python-sqlite2
并尝试遵循 python 代码
and try following python code
try:
import sqlite3
except:
from pysqlite2 import dbapi2 as sqlite3
这篇关于如何将 sqlite3 模块导入 Python 2.4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!