Fixing ModuleNotFoundError: No module named '_sqlite3'
Categories
Today, I set up Flaskr (GitHub repository), one of the Flask demo apps, so that I could poke around Flask a bit.
The only real speed bump was a Note that, to make the above lines from my flaskr error log more readable, I’ve removed the timestamps, process IDs, and requesting IP address. Here’s what one of those lines would look like with those bits left in: A moment’s Googling turned up a number of relevant-looking pages. The kernels of wisdom contained in the top two answers here essentially did the trick: install the When I executed I only thrashed around a little bit (e.g. I did Of these, After restarting Apache (ModuleNotFoundError
for _sqlite3
:
[wsgi:info] mod_wsgi (pid=17417, process=”, application=’example.com|/blog’): Loading WSGI script ‘/home/exampledotcom/flaskr/flaskr.wsgi’.
[wsgi:error] mod_wsgi (pid=17417): Target WSGI script ‘/home/exampledotcom/flaskr/flaskr.wsgi’ cannot be loaded as Python module.
[wsgi:error] mod_wsgi (pid=17417): Exception occurred processing WSGI script ‘/home/exampledotcom/flaskr/flaskr.wsgi’.
[wsgi:error] Traceback (most recent call last):
[wsgi:error] [pid 17417] File “/home/exampledotcom/flaskr/flaskr.wsgi”, line 4, in [Wed Apr 19 19:27:15.518014 2017] [wsgi:error] [pid 17417] [client 112.213.114.126:52163] ModuleNotFoundError: No module named '_sqlite3'
libsqlite3-dev
package on the server and recompile Python.yum -y install libsqlite3-dev
, however, Yum told me:No package libsqlite3-dev available.
Error: Nothing to do
yum clean all
and hoped it might miraculously result in a second try at yum -y install libsqlite3-dev
somehow working) before figuring out the issue. Running yum list | grep -i sqlite | grep dev
yielded the following:sqlite-devel.x86_64 3.7.17-8.el7 @base
golang-googlecode-sqlite-devel.i686 0-0.9.hg74691fb6f837.el7 base
golang-googlecode-sqlite-devel.x86_64 0-0.9.hg74691fb6f837.el7.centos
libodb-sqlite-devel.x86_64 2.3.0-1.el7 epel
soci-sqlite3-devel.x86_64 3.2.3-1.el7 epel
sqlite-devel.i686 3.7.17-8.el7 base
sqlite-devel.x86_64 3.7.17-8.el7 base
sqlite2-devel.x86_64 2.8.17-17.el7 epel
vsqlite++-devel.x86_64 0.3.13-3.el7 epel
sqlite-devel.x86_64
seemed like the best bet, so I installed it (yum -y install sqlite-devel.x86_64
) and moved into the Python 3.6.1 source directory and recompiled Python 3.6.1 like so:./configure --enable-shared --enable-loadable-sqlite-ex
tensions && make && make install
apachectl restart
), I was good to go.