一、centos安装python3
1、安装依赖包:
sudo 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 mysql-devel gcc gcc-devel python-devel
2、下载python3.7的安装包
执行命令 sudo wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tar.xz
3、解压
sudo tar -xvf Python-3.7.7.tar.xz
4、配置安装位置
cd Python-3.7.7
./configure --prefix=/usr/local/python3
5、编译安装
sudo make
sudo make install
6、添加软链接
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3
sudo ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
二、升级系统的sqlite版本(Django需要版本高于3.8.3)
1、下载安装包
sudo wget https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz
2、解压安装包
sudo tar -xvf sqlite-autoconf-3320300.tar.gz
3、配置安装位置
cd sqlite-autoconf-3320300
sudo ./configure --prefix=/usr/local
4、替换系统的sqlite
sudo mv /usr/bin/sqlite3 /usr/bin/sqlite3_old
sudo ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3
sudo echo "/usr/local/lib" > /etc/ld.so.conf.d/sqlite3.conf
sudo ldconfig
三、安装Django
sudo pip3 install Django==3.0.8