Python installation sqlite3 module

Source: Internet
Author: User
Tags sqlite apache log

Python installation Sqlite3  

Environment for Ubuntu16.04 Apache2.4 Python2.7.13 Django 1.8

Today deployed Apache+django, after a variety of toss, finally configured, found the error Apache log there is a

Improperlyconfigured:error loading either PYSQLITE2 or Sqlite3 modules (tried in that order): No module named _sqlite3

You can then open the Python test to import the Sqlite3 module

>>> Import Sqlite3
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/sqlite3/__init__.py", line, in <module>
From DBAPI2 Import *
File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line up, in <module>
From _sqlite3 Import *
Importerror:no module named _sqlite3

The result is no, I used to think that python comes with it,

With PIP install Sqlite3 results can not be installed! As follows:

collecting Sqlite3
Using Cached sqlite3-99.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent):
File "<string>", line 1, in <module>
File "/tmp/pip-build-tpr4m6/sqlite3/setup.py", line 2, <module>
Raise RuntimeError ("package ' sqlite3 ' must not being downloaded from PyPI")
runtimeerror:package ' sqlite3 ' must not being downloaded from PyPI
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in/tmp/pip-build-tpr4m6/sqlite3/

Two blogs on-line reference

Http://www.pythonclub.org/python-files/sqlite and

http://www.python88.com/topic/420/

Download and install SQLITE3

Download sqlite-autoconf-3190300.tar.gz

Download it here in https://sqlite.org/download.html. I downloaded it.

The installation method is:

    1. Extract
    2. ./configure--prefix=/usr/local/lib/python2.7/dist-packages/sqlite3 #目录下面要用的
    3. Make
    4. Make install
    5. After installing the test, see if I can import the Sqlite3 module, I still can't
Then reinstall Python.

Regardless of whether or not Python has been installed, here must be reinstalled, before installation, you need to change the source directory setup.py

You can find the SQLite keyword, find the following line, and add the SQLite installation path at the end

Sqlite_incdir = Sqlite_libdir = None
sqlite_inc_paths = ['/usr/include ',
'/usr/include/sqlite ',
'/usr/include/sqlite3 ',
'/usr/local/include ',
'/usr/local/include/sqlite ',
'/usr/local/include/sqlite3 ',
'/usr/local/lib/python2.7/dist-packages/sqlite3 ',
                           ]

After installation, test again to see if it is successful

1. Method One: First look at whether the Lib has been generated

Or under the/home/user/usr/python/python2.7/lib/python2.7/lib-dynload?

Found _sqlite3.so file

2. Method Two: Use the python command

Sqlite3
No error can be!

Python installation sqlite3 module

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.