参考博客python系列--Python3 No module named '_sqlite3'错误 - 知乎
安装sqlite3
2.1 下载sqlite3安装包
官网地址SQLite Download Page
下载安装包:wget https://www.sqlite.org/2024/sqlite-autoconf-3460000.tar.gz
2.2 上传服务器并进行安装
解压:tar -xvzf sqlite-autoconf-3460000.tar.gz
进入目录:cd sqlite-autoconf-3460000/
编译:./configure --prefix=/usr/local/sqlite
安装 :make && make install
安装完成
2.3 重新安装python3
进入python3安装目录
[root@localhost sqlite-autoconf-3240000]# cd ../Python-3.6.5/
2.4 修改setup.py
[root@localhost Python-3.6.5]# vi setup.py
查找" sqlite_inc_paths" 新增
'/usr/local/sqlite/include'
'/usr/local/sqlite/include/sqlite3'
2.5 编译
[root@localhost Python-3.6.5]# ./configure --enable-loadable-sqlite-extensions
[root@localhost Python-3.6.5]# make && sudo make install
2.6 全局查找_sqlite3.so
[root@localhost Python-3.6.5]# find / -name _sqlite*.so/root/Python-3.6.5/build/lib.linux-x86_64-3.6/_sqlite3.cpython-36m-x86_64-linux-gnu.so
/usr/local/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so
2.7 拷贝 #这一步貌似没用 测试可以成功就不用管了
cp /usr/local/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so /usr/local/python3/lib/python3.6/lib-dynload/_sqlite3.so
2.8 验证
再次进入python环境
执行命令import sqlite3已经可以正常了