In centos6.5, the default Python version is 2.6.6. when I use the latest Django version, I find a syntax error! So I decided to upgrade Python. Step 1: install Python2.7.101. download wgethttp: // www.python.org/ftp/python/2.7.10/python-2.7.10.tgzafter the download is completed:
In centos6.5, the default Python version is 2.6.6. when I use the latest Django version, I find a syntax error! So I decided to upgrade Python. The steps are as follows:
1. install Python 2.7.10
1. Download
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
After the download is complete:
2. extract
tar -xvf Python-2.7.10.tar
3. Compile/install
Create a new directory to use as the installation directory of Python2.7.10.
mkdir /usr/local/python2.7
Then start compiling
Cd Python-2.7.10 # enter the decompressed Python Directory
./Configure -- prefix =/usr/local/python2.7 # wait until compilation is complete
Make & make install # wait for installation
Here, even if Python 2.7.10 is installed, but now the Python version is still 2.6.6 in the command line:
Mv/usr/bin/python/usr/bin/python2.6 # Change the python name of the original version.
To use python, you need to add a new version of python. you can use soft links or add the bin directory of the new version of Python to the PATH.
ln -s /usr/local/python2.7 /usr/bin/python
Or
Vim/etc/profile add the following line export PATH = "/usr/local/python2.7/bin: $ PATH" save and exit source/etc/profile
Enter the python command line to see if the version is 2.7.10 !!!
II. install setuptools
Download:
<> There are multiple methods. here we will introduce one method:
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
Download and get an ez_setup.py file to run it.
python ez_setup.py --insecure
Not surprisingly. Setuptools is successfully installed!
3. install pip
Download:
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
Unzip-install:
tar -xzvf pip-1.5.4.tar.gzcd pip-1.5.4python setup.py install
OK
IV. modify yum
If this step is not performed, yum will report an error
vim /usr/bin/yum
#! /Usr/bin/python changed to the one previously modified #! /Usr/bin/python2.6
Save and exit! OK
V. install MySQLdb
Use pip:
pip install MySQL-python
6. install Django
Pip install django or pip install Django = version
Python has been successfully upgraded to 2.7.10.