Python installation update and PIP installation using Ali and Yum problem resolution __python

Source: Internet
Author: User
Tags mkdir mongodb aliyun
CentOS 7 python version update

Original version 2.7.5 updated version 2.7.13
Note: Because Linux comes with Python, the system has a certain dependence on it, so it is recommended to keep the original version; the Yum function problem is often present; another CentOS version 7 can be installed using Yum for PIP installation, which is faster and easier than manual installation.

1. Install Dependency Pack

Yum-y install gcc
yum install-y zlib-devel bzip2-devel openssl-devel ncurses-devel

2. Package Download:
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

3. Decompression:

TAR-ZXVF python-2.7.13.tgz

4. Create installation directory:

mkdir/usr/local/python2.7.13

5. Switch Directories:

CD Python-2.7.13

6. Compile

./configure--prefix=/usr/local/python2.7.13

Results:

Done
checking for ensurepip ... no
configure:creating./config.status
config.status:creating Makefile.pre
config.status:creating modules/setup.config
config.status:creating misc/python.pc
Config.status:creating Modules/ld_so_aix
config.status:creating pyconfig.h
creating
Modules/setup Creating modules/setup.local
Creating Makefile


If You want-a release builds with all optimizations active (LTO, PG O, etc), please
run./configure--enable-optimizations

Please run./configure–enable-optimizations (this sentence does not execute)

7. Installation:

Make && make install

Results:

Rm-f/usr/local/python2.7.13/share/man/man1/python.1
(cd/usr/local/python2.7.13/share/man/man1; ln-s python2.1 python.1)
if test "xno"!= "Xno"  ; then \ case
        No in \
                upgrade) ensurepip= "--upgrade";
                nstall|*) ensurepip= "";; \
        ESAC \
         /python-e-M ensurepip \
                $ensurepip--root=/; \
fi

8. View the original version, record the original version number

# python  --version
python 2.7.5

9. Updated Version:

[Root@mongodb ~]# which Python
/usr/bin/python
[root@mongodb ~]# Ll/usr/bin/python lrwxrwxrwx
1 root Root 7 May  8 12:09/usr/bin/python-> Python2

Renaming Python as an old version number and establishing a new version of the connection

mv/usr/bin/python/usr/bin/python2.7.5

ln-s/usr/local/python2.7.13/bin/python2/usr/bin/python

10. Verification:

# python-v
python 2.7.13
After the installation is complete, install the PIP:

Using Yum for installation

Yum Install Python-pip

If it appears
No Package Python-pip available.

The solution is as follows:

Yum-y Install epel-release

Yum install Python-pip

Clean up after Setup completes

Yum Clean All

12.PIP Verification

# pip-v
pip 8.1.2 from/usr/lib/python2.7/site-packages (Python 2.7)

13. To improve PIP installation speed, use the domestic pip source, where the PIP source is updated to Ali:

mkdir ~/.pip/
VI ~/.pip/pip.conf

Write:

[Global]
Index-url = http://mirrors.aliyun.com/pypi/simple/

[Install]
trusted-host=mirrors.aliyun.com

14. Installation Flask Verification:

# pip Install flask collecting flask downloading http://mirrors.aliyun.com/pypi/packages/77/32/ E3597CB19FFFFE724AD4BF0BECA4153419918E7FA4BA6A34B04EE4DA3371/FLASK-0.12.2-PY2.PY3-NONE-ANY.WHL (83kB) 100% | ████████████████████████████████| 92kB 660kb/s collecting click>=2.0 (from flask) downloading http://mirrors.aliyun.com/pypi/packages/34/c1/ 8806F99713DDB993C5366C362B2F908F18269F8D792AFF1ABFD700775A77/CLICK-6.7-PY2.PY3-NONE-ANY.WHL (71kB) 100% | ████████████████████████████████| 71kB 1.0mb/s collecting jinja2>=2.4 (from flask) downloading http://mirrors.aliyun.com/pypi/packages/5e/73/ 10C45B82A88ED6B7751BD40DA31EEEFD7B362E07B56A99AA6E56655A0794/JINJA2-2.9.6-PY2.PY3-NONE-ANY.WHL (340kB) 100% | ████████████████████████████████| 348kB 829kb/s collecting werkzeug>=0.7 (from flask) downloading http://mirrors.aliyun.com/pypi/packages/97/02/ 306E0D57FDBF467EC1C763BC1757EC6BA20B1332E0EA7E49111533D71D1C/WERKZEUG-0.12.2-PY2.PY3-NONE-ANY.WHL (312kB) 100% | ████████████████████████████████| 317kB 2.8mb/s collecting itsdangerous>=0.21 (from flask) downloading HTTP://MIRRORS.ALIYUN.COM/PYPI/PACKAGES/DC/B4 /a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz (46kB) 100% | ████████████████████████████████| 51kB 23.1mb/s collecting markupsafe>=0.23 (from jinja2>=2.4->flask) downloading http://mirrors.aliyun.com/
Pypi/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/markupsafe-1.0.tar.gz Installing collected Packages:click, Markupsafe, JINJA2, Werkzeug, itsdangerous, flask Running, setup.py install for Mar Kupsafe ... Running setup.py install for itsdangerous ... done successfully installed jinja2-2.9.6 MarkupSafe-1.0 W erkzeug-0.12.2 click-6.7 flask-0.12.2 itsdangerous-0.24 to are using PIP version 8.1.2, however version 9.0.1 is availabl E. You should consider upgrading via the ' pip install--upgrade pip ' command.

At last
You should consider upgrading via the ' pip install–upgrade Pip ' command.
You can upgrade the PIP using the PIP install–upgrade pip, or you may not need to upgrade, ignoring the Python version update, yum problems occur

Error:
Importerror:no module named Urlgrabber.grabber
Solution:

[Root@mongodb man1]# yum list Loaded plugins:fastestmirror, langpacks base |                                                                                                                                                         3.6 KB 00:00:00 Epel/x86_64/metalink |                                                                                                                                                                         6.3 KB 00:00:00 Epel |                                                                                                                                                                       4.3 KB 00:00:00 Extras |                                                                                                                                  3.4 KB 00:00:00 mongodb-org                                |                                                                                                                                                                      2.5 KB 00:00:00 Updates | 3.4 KB 00:00:00 Traceback (most recent call last): File "/usr/libexec/urlgrabber-ext-down", line, in <module > from urlgrabber.grabber import \ importerror:no module named Urlgrabber.grabber traceback (most recent  ): File "/usr/libexec/urlgrabber-ext-down", line, in <module> from urlgrabber.grabber import \ importerror:  No module named Urlgrabber.grabber traceback (most recent call last): File '/usr/libexec/urlgrabber-ext-down ', line 22, In <module> from Urlgrabber.grabber import \ importerror:no module named Urlgrabber.grabber exiting on user Cancel

A. Modify the path to/usr/bin/yum python:

#vi/usr/bin/yum
The #!/usr/bin/python of the file head to
#!/usr/bin/python2.7.5

When you use Yum installation, you will also encounter
Importerror:no module named Urlgrabber.grabber

Yum install gcc Loaded plugins:fastestmirror, langpacks Loading mirror speeds from cached Hostfile * Base:mirrors.aliyu n.com * epel:mirror01.idc.hinet.net * extras:mirrors.aliyun.com * updates:mirrors.aliyun.com traceback (most recent Call last): File "/usr/libexec/urlgrabber-ext-down", line, in <module> from Urlgrabber.grabber import Imp  Orterror:no module named Urlgrabber.grabber traceback (most recent call last): File "/usr/libexec/urlgrabber-ext-down",  Line by <module> from Urlgrabber.grabber import \ importerror:no module named Urlgrabber.grabber traceback (most recent call last): File "/usr/libexec/urlgrabber-ext-down", line, at <module> from Urlgrabber.grabbe R import \ importerror:no module named Urlgrabber.grabber traceback (most recent call last): File "/usr/libexec/urlgrab Ber-ext-down ", line, in <module> from Urlgrabber.grabber import \ importerror:no module named Urlgrabber.gra Bber Traceback (Most recENT call last): File "/usr/libexec/urlgrabber-ext-down", line, in <module> from urlgrabber.grabber import \ Importerror:no module named Urlgrabber.grabber exiting on user cancel

B./usr/libexec/urlgrabber-ext-down also needs to be modified:

Vi/usr/libexec/urlgrabber-ext-down
The #!/usr/bin/python of the file head to
#!/usr/bin/python2.7.5

At this point, the installation is complete

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.