环境: CentOS_7 (root用户) 软件版本: python_3.7.3
- 安装依赖包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
- 下载软件源码 Python-3.7.3
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
- 解压并编译源码
tar zxvf Python-3.7.3.tgz
cd Python-3.7.3/
./configure --prefix=/usr/local/python-3.7.3
make && make install
- 配置软链接
ln -s /usr/local/python-3.7.3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python-3.7.3/bin/pip3.7 /usr/bin/pip3
- 验证
python3 -V
Python 3.7.3
------
pip3 -V
pip 19.0.3 from /usr/local/python-3.7.3/lib/python3.7/site-packages/pip (python 3.7)
安装最新版本django提示sqlite3版本低,需要更高版本。
###python安装高版本sqlite3
- 安装sqlite3
yum -y install libstdc++.x86_64 glibc.i686 zlib.i686 zlib.x86_64
mv /usr/bin/sqlite3 /usr/bin/sqlite3.bak
wget https://www.sqlite.org/2019/sqlite-autoconf-3300000.tar.gz
tar zxvf sqlite-autoconf-3300000.tar.gz && cd sqlite-autoconf-3300000
./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
ln -s /usr/local/sqlite3/bin/sqlite3 /usr/bin/sqlite3
- 重新编译python
cd Python-3.7.3/
LD_RUN_PATH=/usr/local/sqlite3/lib ./configure --prefix=/usr/local/python-3.7.3 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 sudo make install
- 检测python3.7中sqlite3版本
python3
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.30.0'
来源:oschina
链接:https://my.oschina.net/u/4287258/blog/3509894