Home ModuleNotFoundError: No module named '_sqlite3'解决方法
Post
Cancel

ModuleNotFoundError: No module named '_sqlite3'解决方法

WSL2 ubuntu18.04运行django的时候发现该module缺失

1. 安装编译sqlite3

1
2
3
4
5
 wget https://sqlite.org/2019/sqlite-autoconf-3290000.tar.gz
 tar zxvf sqlite-autoconf-3290000.tar.gz
 cd sqlite-autoconf-3290000
 ./configure
 make && make install

验证安装成功:

img

2. 重新编译python

找到安装路径:

1
2
3
4
5
 $ python -V
 Python 3.10.1
 $ find / -name "Python-3.10.1"
 /root/Python-3.10.1
 /root/Python-3.10.1/build/temp.linux-x86_64-3.10/root/Python-3.10.1

进入该路径,重新编译python:

1
2
3
4
5
6
7
 $cd /root/Python-3.10.1
 $./configure --prefix=/usr/local/python3.10
 $ make && make install
 $which python //查看环境变量python路径
 /usr/bin/python
 $rm -rf /usr/bin/python3.10
 $ln -s /usr/local/python3.10/bin/python3.10 /usr/bin/

验证能否导入该模块:

img

成功解决:

img

This post is licensed under CC BY 4.0 by the author.

Machine Learning: Classification

Machine Learning: Clustering