首先去python官网下载python3的源码包,网址:https://www.python.org/
或者直接wget下载
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
编译之前安装依赖关系
[root@qinhan bin]# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel lib-devel ncurses-devel tk-devel gcc make
释放文件:
tar -xf Python-3.6.4.tgz
进入目录:
cd Python-3.6.4
配置安装目录,其他选项一般默认即可:
./configure --prefix=/application/python-3.6.4
接下来编译源码:
make
执行安装:
make install
更改默认python链接
[root@Poppy bin]# cd /usr/bin/
[root@Poppy bin]# rm -f python
[root@Poppy bin]# ln -s /application/python-3.6.4/bin/python3 /usr/bin/python
[root@Poppy bin]# ln -s /application/python-3.6.4/bin/pip3 /usr/bin/pip3
[root@Poppy bin]# ln -s /application/python-3.6.4/bin/django-admin /usr/bin/django-admin [root@Poppy bin]# python -V # 大写
Python 3.6.4
安装djang-admin命令
[root@Poppy bin]# pip3 install django
建议通过客户端pycharm编写项目
从python2到python3还要更改yum,不然通过yum安装软件时候会报错
[root@Poppy ~]# vi /usr/bin/yum
[root@Poppy ~]# vi /usr/libexec/urlgrabber-ext-down