Chinaunix首页 | 论坛 | 博客
  • 博客访问: 407362
  • 博文数量: 101
  • 博客积分: 2207
  • 博客等级: 大尉
  • 技术积分: 2508
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-19 20:45
文章分类

全部博文(101)

文章存档

2013年(15)

2012年(86)

我的朋友

分类: Python/Ruby

2012-12-09 22:02:28

如果出现如下错误:
>>> import sqlite3
Traceback (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) |
给主人留下些什么吧!~~