ImportError No module named _sqlite3
我在Ubuntu中另外安装了python2.7.9,django项目用2.7.9的这个python解释器,发现该报错
编译安装python,无法导入sqlite3包
解决办法:
安装sqlite:
1. 下载sqlite:
wget http://www.sqlite.org/sqlite-3.6.16.tar.gz
安装:
tar -xzvf sqlite-3.6.16.tar.gz
cd sqlite-3.6.16
./configure --prefix=/usr/local/sqlite3
make && make install
2.重新编译python:
vi Python-2.7.9/setup.py
修改以下部分并重新编译python
...
sqlite_inc_paths = [ '/usr/include',
'/usr/local/sqlite3/include', #增加该部分内容
'/usr/include/sqlite',
'/usr/include/sqlite3',
'/usr/local/include',
'/usr/local/include/sqlite',
3.测试:
Python 2.7.9 (default, Apr 10 2015, 15:10:36)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>>