如果出现如下错误:>>> import sqlite3Traceback (most recent call last): File "", line 1, in File "/picb/extprog/inst/development/python-2.6.2-linux-amd64/lib/python2.6/sqlite3/__init__.py", line 24, in from dbapi2 import * File "/picb/extprog/inst/development/python-2.6.2-linux-amd64/lib/python2.6/sqlite3/dbapi2.py", line 27, in from _sqlite3 import *ImportError: No module named _sqlite3
可以尝试如下办法:
(1) 安装sqlite3
下载 sqlite (如)
安装sqlite, 如果要安装到用户指定目录,可以: $./configure --prefix=/your/path/(我用的/usr/local)
(2) 重新安装python
2.1 先修改python setup.py 文件
在 sqlite_inc_paths 中添加sqlite的include 路径
如:
sqlite_inc_paths = [ '/usr/include',
'/usr/include/sqlite',
'/usr/include/sqlite3',
'/usr/local/include',
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
'~/share/software/python/sqlite-3.6.20/include',
'~/share/software/python/sqlite-3.6.20/include/sqlite3',
]
2.2 安装python
如果要安装到指定目录,可以使用prefix, $./configure --prefix=/your/path/(我用的/usr/local)
(3) 检测安装是否成功
>>import sqlite3
阅读(2503) | 评论(0) | 转发(1) |