一 .解决python编译安装所需的软件依赖
yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y
二 下载python3.6源码包
1,在服务器opt目录下输入
wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tar.xz
2,shell窗口输入xz -d Python-3.6.7.tar.xz
3,tar -xf Python-3.6.7.tar #解压缩,生成一个python源码文件夹
4, 进入Python-3.6.7文件夹
cd Python-3.6.7
5,进行编译安装:
1, ./configure --prefix=/opt/python36/
--prefix 参数解释:指定python36安装的位置
2,直接在当前目录输入 :
make && make install 等同于先输入make 等make运行完再输入 makeinstall
6,进入python36安装目录 ,检查bin目录是否存在
7.配置python3的环境变量 PATH
1.取出当前的path变量
echo $PATH
2.填写python3的bin目录到PATH中
PATH="/opt/python36/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
3.将环境变量,写入到全局配置文件/etc/profile
vim /etc/profile
4.写入如下代码,在最底行写入如下配置
PATH="/opt/python36/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
5.读取配置文件,加载变量生效
source /etc/profile
8:升级pip
pip3 install --upgrade pip
三: 安装Django:
1,在opt目录下输入
pip3 install -i https://pypi.douban.com/simple django==1.11.14
原文地址:https://www.cnblogs.com/16795079a/p/10608656.html