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:
- Extract
- ./configure--prefix=/usr/local/lib/python2.7/dist-packages/sqlite3 #目录下面要用的
- Make
- Make install
- 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