First step: Upgrade Python
CentOs 6.x's system default installed Python version is 2.6.x, want to upgrade to python2.7.x, from the official download source files, and then unzip, compile
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
unxz python-2.7.10.tar.xz
tar-vxf Python-2.7.10.tar
Executing the above command will extract the Python-2.7.10 this folder, enter the directory and execute the following command to configure
./configure--enable-shared--enable-loadable-sqlite-extensions--with-zlib
--enable-loadable-sqlite-extensions
This is an extension of the SQLite, with this option if needed.
Before compiling, you need to modify the setup file to remove the annotations we need to compile the zlib
Locate and #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
Save the annotation and then compile and install it
After installing the Python2.7 we need to back up the Python2.6 and then modify the Yum configuration, and if you don't do this, executing the Yum command will prompt you for the wrong version of Python. Perform the following command, back up the Python2.6, and then create a soft link for Python2.7:
mv/usr/bin/python/usr/bin/python2.6.6
ln-s/usr/local/bin/python2.7/usr/bin/python
Then edit /usr/bin/yum
to change the first line #!/usr/bin/python
to#!/usr/bin/python2.6.6
There is no previous error message executing the yum command. We perform python-v view version information, if an error occurs
Error while loading shared Libraries:libpython2.7.so.1.0:cannot open Shared object file:no such file or directory
Edit configuration file
Add a new line of content /usr/local/lib
, save the exit, and then
/sbin/ldconfig
/sbin/ldconfig-v
Step Two: Install Pip
Download the latest version of the PIP, and then install
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
Find the location of the PIP
Find the path to pip2.7 and create a soft chain for it as the default boot version of the system
Ln-s/usr/local/bin/pip2.7/usr/bin/pip
Pip installed, now you can use it to install a variety of requirements of the package:)
Step Three: Install Scrapy
pip install scrapy
it's just OK.
Summarize
The above is the CentOS 6.X system upgrade Python2.6 to Python2.7 all the steps, we have learned? Hope this article for everyone's study or work to bring certain help.