Learn about Centmin Mod LEMP Stack today
Become a Member

Sysadmin Python 2.7 will reach the end of its life on January 1st, 2020. Running out of time

Discussion in 'System Administration' started by EckyBrazzz, Dec 8, 2019.

  1. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    6:33 AM
    Latest
    Latest
    Hi there,

    What do we do with Python? Just installed it, but ehhh, 1/1/2020 is just around the corner.
    Code (Text):
    DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support


    I found some things on the internet, but Centmin is just a little differente and I don't want to break anything

    How to install the latest version of Python on CentOS - Daniel Eriksson
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    7:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    CentOS Python 2.7 usually gets backported updates to same version. So that message is just cosmetic - you do not overwrite and upgrade system Python 2.7 on CentOS otherwise you break CentOS and possibly YUM itself so won't be able to update via YUM and break any system dependencies on Python 2.7.

    You can install Python 3.6 side by side with Python 2.7 via Centmin Mod 123.09beta01's addons/python36_install.sh and you'd have pip3.6 and python3.6 access to 3.6 version
    Code (Text):
    python --version
    Python 2.7.5
    
    python3.6 --version
    Python 3.6.8
    

    then if your python app needs python 3.6, you can use virtualenv to setup sandbox for python 3.6 similar to outline at How to install the latest version of Python on CentOS - Daniel Eriksson under Create your first isolated Python environment header instead though of pip2.7 it's just pip for 1st step.

    virtualenv and pipenv are 2 was of creating sandboxes see Pipenv & Virtual Environments — The Hitchhiker's Guide to Python along with virtualenvwrapper

    example for virtualenv using python3.6 interpreter
    Code (Text):
    pip install virtualenv
    mkdir -p /home/python_projects
    cd /home/python_projects
    virtualenv -p /usr/bin/python3.6 venv1
    source venv1/bin/activate
    
    # pip doesn't like ccache so disable it
    export CC='gcc'
    export CXX="g++"
    
    # pip needs a tmp directory that doesn't have noexec restrictions
    mkdir -p /home/piptmp
    chmod 1777 /home/piptmp
    export TMPDIR=/home/piptmp
    
    # update pip defined by -p flag to use python3.6 binary
    pip install -U pip
    pip --version
    

    Code (Text):
    virtualenv -p /usr/bin/python3.6 venv1
    Running virtualenv with interpreter /usr/bin/python3.6
    Already using interpreter /usr/bin/python3.6
    Using base prefix '/usr'
      No LICENSE.txt / LICENSE found in source
    New python executable in /home/python_projects/venv1/bin/python3.6
    Also creating executable in /home/python_projects/venv1/bin/python
    Installing setuptools, pip, wheel...
    done.
    

    Code (Text):
    source venv1/bin/activate
    pip install -U pip
    Requirement already up-to-date: pip in ./venv1/lib/python3.6/site-packages (19.3.1)
    (venv1)
    
    pip --version
    pip 19.3.1 from /home/python_projects/venv1/lib/python3.6/site-packages/pip (python 3.6)
    

    python/pip binaries installed in virtual environment called venv1 in bin directory at /home/python_projects/venv1/bin
    Code (Text):
    ls -lah /home/python_projects/venv1/bin/
    total 84K
    drwxr-xr-x 2 root root 4.0K Dec  7 19:55 .
    drwxr-xr-x 5 root root 4.0K Dec  7 19:54 ..
    -rw-r--r-- 1 root root 2.2K Dec  7 19:54 activate
    -rw-r--r-- 1 root root 1.5K Dec  7 19:54 activate.csh
    -rw-r--r-- 1 root root 3.1K Dec  7 19:54 activate.fish
    -rw-r--r-- 1 root root 1.8K Dec  7 19:54 activate.ps1
    -rw-r--r-- 1 root root 1.5K Dec  7 19:54 activate_this.py
    -rw-r--r-- 1 root root 1.2K Dec  7 19:54 activate.xsh
    -rwxr-xr-x 1 root root  245 Dec  7 19:55 cygdb
    -rwxr-xr-x 1 root root  266 Dec  7 19:55 cython
    -rwxr-xr-x 1 root root  246 Dec  7 19:55 cythonize
    -rwxr-xr-x 1 root root  255 Dec  7 19:54 easy_install
    -rwxr-xr-x 1 root root  255 Dec  7 19:54 easy_install-3.6
    -rwxr-xr-x 1 root root  242 Dec  7 19:54 pip
    -rwxr-xr-x 1 root root  242 Dec  7 19:54 pip3
    -rwxr-xr-x 1 root root  242 Dec  7 19:54 pip3.6
    lrwxrwxrwx 1 root root    9 Dec  7 19:54 python -> python3.6
    lrwxrwxrwx 1 root root    9 Dec  7 19:54 python3 -> python3.6
    -rwxr-xr-x 1 root root  12K Dec  7 19:54 python3.6
    -rwxr-xr-x 1 root root 2.3K Dec  7 19:54 python-config
    -rwxr-xr-x 1 root root  233 Dec  7 19:54 wheel
    

    Direct access to venv1 sandbox's version of python 3.6 and pip 3.6 to install python packages will end up in /home/python_projects/venv1/ sandbox directory not to polute system python 2.7
    Code (Text):
    /home/python_projects/venv1/bin/python3.6 --version
    Python 3.6.8
    
    /home/python_projects/venv1/bin/pip3.6 --version
    pip 19.3.1 from /home/python_projects/venv1/lib/python3.6/site-packages/pip (python 3.6)
    
    /home/python_projects/venv1/bin/pip --version
    pip 19.3.1 from /home/python_projects/venv1/lib/python3.6/site-packages/pip (python 3.6)
    
     
    Last edited: Dec 8, 2019
  3. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    6:33 AM
    Latest
    Latest
  4. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    7:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    FYI Redhat and CentOS Python 2 support after 2020 statement How is Python 2 supported in RHEL after 2020? - Red Hat Customer Portal

     
  5. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    6:33 AM
    Latest
    Latest
    @eva2000 interesting, but our current install, Centos 7.7, will it be updated to Centos 8.x when you're done testing it?

    In that case Python also will be the newer supported version.
     
  6. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    7:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    CentOS doesn't support in place major version upgrades. To upgrade from CentOS 7.7 to 8.0/8.1, need to reinstall OS or install CentOS 8/8.1 on another server and migrate data. Just as well as in place upgrades would rely on 3rd party YUM repo haven't equivalent YUM pages but CentOS 7.7 vs 8.x EPEL do not have equivalent packages and EPEL 8 has some missing and some renamed.
     
  7. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    6:33 AM
    Latest
    Latest
    Distro upgrade always was a painfull event. Most distros I tried failed on that part, even if they mention that It won't. But haevy modding a distro can be an issue for that one.

    Even the switch from PHP 7.3.x to 7.4.0. I'm currently switching up and down, notice, he, something ain't working.

    One side, always nice to startup from 0, have a clean a fresh server, install all things again, remove little "mistakes" made in the past. Most of the time you end up with a server that runs better.
    Now in Centos we need to learn a bit how it works, go ahead and play a bit with it. Can't hurt, and we are ready to switch to the new Centos 8.x.

    Those who are here on Cenmin Mod know that everynote is a great tool to do your homework, note everything down, and even the most experienced Cenmin Mod users have SecureCRT and many other tools. (Thx RTFM);)

    @eva2000 do you have an estimated date?:peeking: So, that we have a slightly have an idea when to create our new and fresh servers?:peeking:

    My 2 cents are on the next flight to Australia, planned next year also, just have to do some check on the site of the border control what you are allowed to take with you. Always check that before traveling. It avoids GST and here it has another name:)
     
  8. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    7:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  9. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    6:33 AM
    Latest
    Latest
    Issue resolved permanent

    Code (Text):
    python 
    Python 3.6.9 (default, Nov 11 2019, 11:24:16) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    


    Seems there is nothing broken, result after full reboot of the server