赞
踩
运行python程序的时候,报错Python3 No module named '_sqlite3';
操作步骤:
- 下载安装包:wget https://www.sqlite.org/2018/sqlite-autoconf-3240000.tar.gz
- 解压:tar -xvzf sqlite-autoconf-3240000.tar.gz
- 进入目录:cd sqlite-autoconf-3240000/
- 编译:./configure --prefix=/usr/local/sqlite
- 安装 :make -j4&&sudo make install
安装成功后,继续重新安装python3
进入python3目录,修改setup.py
[root@localhost Python-3.7]# vi setup.py
查找" sqlite_inc_paths" 新增
'/usr/local/sqlite/include'
'/usr/local/sqlite/include/sqlite3'
接下来执行:
[root@localhost Python-3.7]# ./configure --enable-loadable-sqlite-extensions
[root@localhost Python-3.7]# make && sudo make install[root@localhost Python-3.7]# find / -name _sqlite*.so
发现python3 多了
/root/Python-3.7/build/lib.linux-x86_64-3.6/_sqlite3.cpython-36m-x86_64-linux-gnu.so
/usr/local/lib/python3.7/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so
接下来我们在执行:
cp /usr/local/lib/python3.7/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so /usr/local/python3/lib/python3.7/lib-dynload/_sqlite3.so
再次进入python环境
执行命令import sqlite3已经可以正常了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。