Tag Archives: import sqlite3

Using pyenv causes the problem that python3 cannot import SQLite3

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Questions

I want to install a jupyter to use the functions of notebook. However, when I execute jupyter notebook , I report an error directly

ModuleNotFoundError: No module named '_sqlite3'

Strange, isn’t python3 supported by SQLite3?Solution

Looking at the mistakes, I remember that my Linux version of Python is managed by pyenv, so now 3.7.4 is actually installed by pyenv install 3.7.4 . Pyenv installation, in fact, is to download the source code from the official website to compile and install, so think of it, is it difficult because the SQLite3 development package is not installed

Try to execute sudo apt install libsqlite3 dev , and it is not installed

After the installation is completed, you can go over pyenv install 3.7.4 , ask if you want to re install it, then download the source code from the official website and compile it. It takes about 10 minutes to compile, execute Import SQLite3 , and it’s OK

Postscript

It seems that pyenv also has trouble managing python. After that, I don’t know how many functions are available because it doesn’t have any dependencies installed, so it doesn’t turn on this feature directly