end0tknr's kipple - 新web写経開発

http://d.hatena.ne.jp/end0tknr/ から移転しました

「ModuleNotFoundError: No module named '_sqlite3'」には「./configure --enable-loadable-sqlite-extensions」からの python 3.7の再installが必要

$ ./foo_6_1.py 
Traceback (most recent call last):
  File "./foo_6_1.py", line 7, in <module>
    from google.colab import drive
  File "/usr/local/python3/lib/python3.7/site-packages/google/colab/__init__.py", line 25, in <module>
    from google.colab import auth
  File "/usr/local/python3/lib/python3.7/site-packages/google/colab/auth.py", line 26, in <module>
    import sqlite3 as _sqlite3  # pylint: disable=g-bad-import-order
  File "/usr/local/python3/lib/python3.7/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/python3/lib/python3.7/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

というエラーが発生。

どうやら、「yum install sqlite-devel」と、python の再installが必要らしい。

$ yum install sqlite-devel

# ↓次に既にinstall済のpython moduleの一覧作成
$ sudo /usr/local/python3/bin/pip freeze > requirements.txt

# ↓「--enable-loadable-sqlite-extensions」を追加し、python本体の再install
$ ./configure --prefix=/usr/local/python3 \
            --enable-loadable-sqlite-extensions \
        --enable-optimizations
$ make
$ sudo make install

# ↓先程の requirements.txt で python module群も再install
$ sudo /usr/local/python3/bin/pip install -r requirements.txt

上記により「ModuleNotFoundError: No module named '_sqlite3'」は解消されました。

ただ、以下のような warning が発生するようになりました。 まぁ、warning ですので、今後、気が向いたら調べます。

$ ./foo_6_1.py 
/usr/local/python3/lib/python3.7/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
  warn("IPython.utils.traitlets has moved to a top-level traitlets package.")