Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of installing Python2.7 and Python2.6 in CentOS

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Recently bought VPS with CentOS service system, used to use Ubuntu when Linux is quite easy to use, but these days using CentOS let me have a new understanding of Linux, Linux can also drive you crazy! I installed Python2.7 on the original system after a variety of problems, a variety of libraries can not be found ah! Because many libraries in ContOS depend on Python2.6, there will be various problems after installing Python2.7. If the two versions can coexist well, this problem can be solved. Later, I found a blog post that solved my problem, and now it points out a direction for people who have the same problems as me.

First update yum and install the development toolset

Yum-y updateyum groupinstall-y'development tools'

Then install the packages needed by the python tool (otherwise there will be an error in installing setuptools and pip, and then prompt to find out what files are missing, so install them in advance).

Yum install-y zlib-devel bzip2-devel openssl-devel xz-libs wget

Install Python2.7 with source code

/ / download the source code wget http://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz// decompressed file xz-d Python-2.7.13.tar.xztar-xvf Python-2.7.13.tar// into the unzipped folder cd Python-2.7.13// running configuration. / configure-- prefix=/usr/local// compiles and installs makemake altinstall

Maybe what you see elsewhere is make install, and I use make altinstall here. Because altinstall does not have to affect the original python version.

Set up a soft connection

Ln-s / usr/local/bin/python2.7 / usr/bin/python

After a soft connection, it's time for us to use the python command to point to our version 2.7 of python.

Install setuptools

/ / download the source code wget-- no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz// extract file tar-xvf setuptools-1.4.2.tar.gz// into the decompressed folder cd setuptools-1.4.2// to install python2.7 setup.py install

Install pip

Curl https://bootstrap.pypa.io/get-pip.py | python2.7

Resolve the problem that yum cannot be used

Because yum does not support pthon2.7, you will find that yum cannot be used after the above steps, and python2.6 is not removed during installation above, so we can only specify the python version of yum.

/ / Open yumvi / usr/bin/yum with an editor

Change the first line #! / usr/bin/python to #! / usr/bin/python2.6

Now run yum to see if it works.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 259

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report