zzh@ZZHPC:~/.pyenv/bin$ ./pyenv install 3.13.5
Downloading Python-3.13.5.tar.xz...
-> https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz
Installing Python-3.13.5...
Traceback (most recent call last):
File "<string>", line 1, in <module>
import sqlite3
File "/home/zzh/.pyenv/versions/3.13.5/lib/python3.13/sqlite3/__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
File "/home/zzh/.pyenv/versions/3.13.5/lib/python3.13/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Installed Python-3.13.5 to /home/zzh/.pyenv/versions/3.13.5
✅ Root Cause
When building Python from source (as pyenv does), it needs the development headers and libraries of dependencies like SQLite, zlib, OpenSSL, etc.
In your case, Python found the sqlite3 Python wrapper, but could not find the native _sqlite3 C extension, because the SQLite C library and its headers were missing.
zzh@ZZHPC:~/.pyenv/bin$ ./pyenv uninstall 3.13.5 pyenv: remove /home/zzh/.pyenv/versions/3.13.5? (y/N) y pyenv: 3.13.5 uninstalled
zzh@ZZHPC:~/.pyenv/bin$ sudo apt install libsqlite3-dev
zzh@ZZHPC:~/.pyenv/bin$ ./pyenv install 3.13.5 Downloading Python-3.13.5.tar.xz... -> https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz Installing Python-3.13.5... Installed Python-3.13.5 to /home/zzh/.pyenv/versions/3.13.5

浙公网安备 33010602011771号