布署到centos7.9时,ModuleNotFoundError No module named ‘_sqlite3‘

先下载编译sqlite3 wget http://www.sqlite.org/sqlite-3.5.6.tar.gz

cd sqlite-3.5.6 ./configure --disable-tcl make && make install

注意add LIBDIR to the ‘LD_LIBRARY_PATH’ environment variable,这是sqlite建议添加环境变量。 所以:

echo export LD_LIBRARY_PATH=/usr/local/lib >> /etc/profile source /etc/profile

再下载编译python3.6.7 wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tar.xz ./configure LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" --prefix=/usr/bin make && make install 将安装后的so文件复制到你正在使用的python的相应目录下 cp /usr/bin/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so /usr/bin/python367/lib/python3.6/

还是没有成功!!!

[root@usr]# rm -f /usr/lib64/libsqlite3.so.0.8.6 [root@usr]# rm -f /usr/lib64/libsqlite3.so [root@ usr]# rm -f /usr/lib64/libsqlite3.so.0

将/usr/lib64/libsqlite3.so.0这3个文件删除并替换,重新编译python3安装就能够成功了

旧版本可能失败,最好是安装最新版本的sqlite,查找下

find / -name  _sqlite3.cpython*

出现如下,基本就稳了

/usr/local/lib/python3.8/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so

posted @ 2024-04-08 09:52  木头左  阅读(6)  评论(0编辑  收藏  举报