カカドゥ開発者ブログ

株式会社カカドゥのエンジニアブログです。Python, Django, SEO成分が多めです。

手動ビルドしたPythonでDjangoのrunserverしたらNo module named _sqlite3というエラーが出た

こんにちはカカドゥの増田です。

手動でビルドしたPython(2.7.10)で、Djangoのrunserverをしようとしたとき、以下のようなエラーに遭遇しました。

raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3

_sqlite3というモジュールが見つからなくて発生したらしい。

makeしたときのログを確認したところ_sqlite3がビルドできなかった旨のメッセージが出てました。

Python build finished, but the necessary bits to build these modules were not found:
_bsddb             _curses            _curses_panel   
_sqlite3           _tkinter           bsddb185        
bz2                dbm                dl              
gdbm               imageop            sunaudiodev     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Ubuntuだとlibsqlite3-devというライブラリをインストールしてからビルドし直せば解決しました。

$ sudo apt-get install libsqlite3-dev