ModuleNotFoundError: No module named ‘sqlite‘的解决方案

之前在内网centos服务器已经离线安装python3,建立虚拟环境并安装需要用到的库,安装好后将项目copy过来,运行时报错:

ModuleNotFoundError: No module named '_sqlite3'

在centos7环境中常规安装python3的话无法支持sqlite3,所以在安装pytho3是需要带上sqlite3库:
下载编译安装sqlite3:
# wget https://www.sqlite.org/2018/sqlite-autoconf-3250300.tar.gz --no-check-certificate
# ./configure --prefix=/usr/local/sqlite3 --disable-static --enable-fts5 --enable-json1 CFLAGS="-g -O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_RTREE=1"
# make && make install

完成编译sqlite3后,在进行编译安装python3(已经完成编译安装的话,需要重新编译安装)
这边曾经安装过,所以直接进解压后的python包中,需要注意的是,需要将之前安装的python3给删掉(至于不删掉直接装我没试过)

# cd python3.6.8
# LD_RUN_PATH=/usr/local/sqlite3/lib ./configure --prefix=/usr/local/python3 --with-ssl LDFLAGS="-L /usr/local/sqlite3/lib" CPPFLAGS=" -I /usr/local/sqlite3/include"
# LD_RUN_PATH=/usr/local/sqlite3/lib make
# LD_RUN_PATH=/usr/local/sqlite3/lib make install
ok,重新安装完毕,再次启动,报错:
cryptography is required for sha256_password or caching_sha2_password
…虽然出错,但是sqlite的问题解决了
—7.24更新----
ssl也会报错,需要重新编译

你可能感兴趣的:(CentOS8,python,centos,sqlite3,linux,运维)