前言
目前的网站八成都是 PHP,但是 python 自己有着强大的数学计算库,为数据挖掘和分析做保证。
安装
Python
找东西一定要去官网,对于国内的网络环境来讲,百度出来的文章更多的都是两三年前的,没有什么参考价值,还会耽误时间。
首先是安装 Python,centos7自带 Python2.7
什么版本python 可以安装 Django
还是有问题去官网的风格
What Python version can I use with Django?¶
Django version Python versions
1.4 2.5, 2.6, 2.7
1.7, 1.8 2.7 and 3.2, 3.3, 3.4
1.9 2.7, 3.4, 3.5
For each version of Python, only the latest micro release (A.B.C) is officially supported. You can find the latest micro version for each series on the Python download page.Typically, we will support a Python version up to and including the first Django LTS release whose security support ends after security support for that version of Python ends. For example, Python 3.3 security support ends September 2017 and Django 1.8 LTS security support ends April 2018. Therefore Django 1.8 is the last version to support Python 3.3.
手动升级 python3.4.3
为什么不是3.3呢,因为3.4是比较新的版本,并且Django也是支持的,3.3版本到现在时间有些长。。。
官网下载
通过 wget 对官网安装包进行下载
wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
解压编译安装
tar -xf Python-3.4.3.tar.xz
cd Python-3.4.3/
./configure出错了 Ignoring ensurepip failure: pip 6.0.8 requires SSL/TLS
yum -y install openssl openssl-devel
Successfully installed pip-6.0.8 setuptools-12.0.5
建立3.4.3的链接
rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.4 /usr/bin/python注意:将默认的python指向3.4.3以后,yum不能正常使用,需编辑下yum的配置文件:vi /usr/bin/yum
这里需要先将原来的python软连接重名 mv /usr/bin/python /usr/bin/python2.7.5
把文件头部的#!/usr/bin/python改成#!/usr/bin/python2.7.5保存退出即可;