ImportError: No module named _sqlite3

编译安装python,无法导入sqlite3包

解决办法:

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
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
>>>


你可能感兴趣的:(python,error,sqlite3)