Skip to content

Instantly share code, notes, and snippets.

@okanon
Created October 15, 2017 17:02
Show Gist options
  • Save okanon/cabb01f043610d23f4ac01470dbcd907 to your computer and use it in GitHub Desktop.
Save okanon/cabb01f043610d23f4ac01470dbcd907 to your computer and use it in GitHub Desktop.
CentOS6.5 latest Python2 and Python3 install except pyenv

Latest Python2 and Python3 install CentOS6.5 except Pyenv

Install

Python2.6.6 is installed by default in CentOS 6.5. Since python2.6.6 is used in yum, Install the latest python 2 and python 3 including pip, without breaking this environment. At this time, except pyenv.

  1. When installing pip, curl: (35) SSL connect error error occurs, so upgrade libcurl to the latest version as follows. And, in order to fix zipimport.ZipImportError: can not decompress data; zlib not available which occurs when installing pip as well, execute yum upgrade after installing the package.

        yum install libcurl
    
        sudo rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm
        sudo vim /etc/yum.repos.d/city-fan.org.repo
        sudo yum update --enablerepo=city-fan.org libcurl
    
        yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel
        yum upgrade
  2. Install python. Here we install Python 2.7.14 and Python 3.6.3. Python 3.7.0a1 is not recommended as it will cause installation errors.

        mkdir /usr/local/src
        cd /usr/local/src
    
        curl -O https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
        tar zxf Python-2.7.14.tgz
    
        cd Python-2.7.14
    
        ./configure
        make && make altinstall
  3. Replace the default Python with the latest version without deleting Python2.6.6. At this time, do not influence yum.

        rm -rf /usr/bin/python2 /usr/bin/python2.6
        mv /usr/bin/python /usr/bin/python26
    
        vi /usr/bin/yum  ##python -> python26
    
        mv /usr/local/src/Python-2.7.14/python /usr/bin/python
        
        python --version
        # Python 2.7.14
        python26 --version
        # Python 2.6.6
  4. Install pip.

        curl -kL https://bootstrap.pypa.io/get-pip.py | python
        pip -V
        # pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
@okanon
Copy link
Author

okanon commented Oct 20, 2017

Although it is unknown whether there is a relation, If you install Python using the above method, errors like libpython/Python2.7.a may occur.
Currently, when trying to install "uwsgi", this error has occurred in both pip install and make.

I plan to write countermeasures at a later date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment