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

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

安装编译sqlite3

 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

验证安装成功

ModuleNotFoundError: No module named ‘_sqlite3‘解决方法_第1张图片

重新编译python

找到安装路径

 $ 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

 $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/

验证能否导入该模块:

ModuleNotFoundError: No module named ‘_sqlite3‘解决方法_第2张图片

成功解决:

ModuleNotFoundError: No module named ‘_sqlite3‘解决方法_第3张图片

 

你可能感兴趣的:(python,django,sqlite,后端)