Original connection:
http://blog.csdn.net/jaket5219999/article/details/53512071
System Red hat6.7 also centos6.7 python3.5.2 after installing Django, create project and import Sqlite3
All appear No module named ' _sqlite3′
>>> Import Sqlite3
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "/opt/python-3.5.0/python350/lib/python3.5/sqlite3/__init__.py", line at <module>
From SQLITE3.DBAPI2 Import *
File "/opt/python-3.5.0/python350/lib/python3.5/sqlite3/dbapi2.py", line +, in <module>
From _sqlite3 Import *
Solve:
1, yum-y install Sqlite-devel
2, CD Python-3.5.2 (Python source installation files after extracting the folder)
3./configure--enable-loadable-sqlite-extensions--prefix=/opt/python352 (--prefix may be added)
4. Make && make install
If these steps are not working, repeat the third and fourth steps after modifying the setup.py file in the Python-3.5.2 folder:
Add the include path to SQLite in Sqlite_inc_paths
Such as:
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 is the installation path for SQLite)
' ~/share/software/python/sqlite-3.6.20/include/sqlite3 ',
]
Second, if the python2.7 appears import sqlite3 can not find the problem of _sqlite module, it is much simpler
1. # Find/-name _sqlite*.so
/usr/lib64/python2.6/lib-dynload/_sqlite3.so
2. # Whereis python2.7
Python2:/usr/bin/python2.7/usr/bin/python2/usr/bin/python2.6/usr/lib/python2.6/usr/lib64/python2.6/usr/local/ bin/python2.7/usr/local/bin/python2.7-config/usr/local/bin/python2/usr/local/lib/python2.7/usr/include/ python2.6
3, cp/usr/lib64/python2.6/lib-dynload/_sqlite3.so/usr/local/lib/python2.7/lib-dynload/_sqlite3.so
OK, get it done!
CENTOS6 Python installs SQLite to resolve No module named ' _sqlite3′