CENTOS6 Python installs SQLite to resolve No module named ' _sqlite3′

Source: Internet
Author: User
Tags sqlite

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′

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.