Skip to content

Instantly share code, notes, and snippets.

@cuibonobo
Last active April 30, 2024 13:13
Show Gist options
  • Save cuibonobo/a81e3b4ae0125a681e1f to your computer and use it in GitHub Desktop.
Save cuibonobo/a81e3b4ae0125a681e1f to your computer and use it in GitHub Desktop.
Install Python 2.7.15 on CentOS 6

These instructions were mostly taken from here, though I've modified them to install Python 2.7.15 and the latest setuptools package.

# Install dependencies
yum groupinstall -y 'development tools'
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget

# Download the Python source and unpack it
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
tar -xvzf Python-2.7.15.tgz

# Enter the directory, configure, and install
cd Python-2.7.15
./configure --prefix=/usr/local
make
make altinstall

# Check the Python version with `python2.7 -V` and make sure
# /usr/local/bin is in your `PATH` with `echo $PATH`. If not
# do `export PATH="/usr/local/bin:$PATH"`

# Install `setuptools`
cd ..
wget https://files.pythonhosted.org/packages/b0/d1/8acb42f391cba52e35b131e442e80deffbb8d0676b93261d761b1f0ef8fb/setuptools-40.6.2.zip
unzip setuptools-40.6.2.zip
cd setuptools-40.6.2
python2.7 setup.py install

# Install `pip`
curl https://bootstrap.pypa.io/get-pip.py | python2.7 -

# Install `virtualenv`
pip2.7 install virtualenv
@onovaes
Copy link

onovaes commented Apr 29, 2019

Dont work in CentOS release 6.10 (Final)

[root@0b85bc700743 Python-2.7.15]# python2.7 -V
bash: python2.7: command not found

@gnerdalot
Copy link

gnerdalot commented Apr 23, 2020

Thank you ! This helped me on an older system. For the final step, curl'd down the file and just ran it, and needed to pip install setuptools...

% sudo /usr/local/bin/python2.7 get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. 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
Collecting pip
  Downloading pip-20.0.2-py2.py3-none-any.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 1.6 MB/s
Collecting wheel
  Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Installing collected packages: pip, wheel
Successfully installed pip-20.0.2 wheel-0.34.2

setuptools then virtualenv:

Collecting filelock<4,>=3.0.0
  Downloading filelock-3.0.12.tar.gz (8.5 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python2.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-99NUnX/filelock/setup.py'"'"'; __file__='"'"'/tmp/pip-install-99NUnX/filelock/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-99NUnX/filelock/pip-egg-info
         cwd: /tmp/pip-install-99NUnX/filelock/
    Complete output (3 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named setuptools
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

% sudo /usr/local/bin/pip2.7 install setuptools
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. 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
Collecting setuptools
  Downloading setuptools-44.1.0-py2.py3-none-any.whl (583 kB)
     |████████████████████████████████| 583 kB 1.6 MB/s
Installing collected packages: setuptools
Successfully installed setuptools-44.1.0

% sudo /usr/local/bin/pip2.7 install virtualenv
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. 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
Collecting virtualenv
  Using cached virtualenv-20.0.18-py2.py3-none-any.whl (4.6 MB)
Collecting importlib-metadata<2,>=0.12; python_version < "3.8"
  Using cached importlib_metadata-1.6.0-py2.py3-none-any.whl (30 kB)
Collecting pathlib2<3,>=2.3.3; python_version < "3.4" and sys_platform != "win32"
  Using cached pathlib2-2.3.5-py2.py3-none-any.whl (18 kB)
Collecting importlib-resources<2,>=1.0; python_version < "3.7"
  Using cached importlib_resources-1.4.0-py2.py3-none-any.whl (20 kB)
Collecting filelock<4,>=3.0.0
  Using cached filelock-3.0.12.tar.gz (8.5 kB)
Collecting contextlib2<1,>=0.6.0; python_version < "3.3"
  Downloading contextlib2-0.6.0.post1-py2.py3-none-any.whl (9.8 kB)
Collecting appdirs<2,>=1.4.3
  Downloading appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Collecting six<2,>=1.9.0
  Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
Collecting distlib<1,>=0.3.0
  Downloading distlib-0.3.0.zip (571 kB)
     |████████████████████████████████| 571 kB 2.2 MB/s
Collecting zipp>=0.5
  Downloading zipp-1.2.0-py2.py3-none-any.whl (4.8 kB)
Collecting configparser>=3.5; python_version < "3"
  Downloading configparser-4.0.2-py2.py3-none-any.whl (22 kB)
Collecting scandir; python_version < "3.5"
  Downloading scandir-1.10.0.tar.gz (33 kB)
Collecting typing; python_version < "3.5"
  Downloading typing-3.7.4.1-py2-none-any.whl (26 kB)
Collecting singledispatch; python_version < "3.4"
  Downloading singledispatch-3.4.0.3-py2.py3-none-any.whl (12 kB)
Building wheels for collected packages: filelock, distlib, scandir
  Building wheel for filelock (setup.py) ... done
  Created wheel for filelock: filename=filelock-3.0.12-py2-none-any.whl size=7578 sha256=4599ca2ba567253f7f3d9791c6d0763febb1bdbdcdeb3db5600ab01877882ec9
  Stored in directory: /root/.cache/pip/wheels/b9/91/23/b559c1f4fd55056712b3a71cd9cab1dc0089e2232d502ed72e
  Building wheel for distlib (setup.py) ... done
  Created wheel for distlib: filename=distlib-0.3.0-py2-none-any.whl size=340428 sha256=e579aad6849f6e6940719dc95519a496e784be5eeddac83e269f311910bbc301
  Stored in directory: /root/.cache/pip/wheels/0c/88/ac/41500883ea902d3409a83a827870a726346b5ebfd0523e91df
  Building wheel for scandir (setup.py) ... done
  Created wheel for scandir: filename=scandir-1.10.0-cp27-cp27m-linux_x86_64.whl size=33520 sha256=3e66ff1761af15c568a20ef23bacde71e1e46edaf77fcb1993068e43567e4ada
  Stored in directory: /root/.cache/pip/wheels/58/2c/26/52406f7d1f19bcc47a6fbd1037a5f293492f5cf1d58c539edb
Successfully built filelock distlib scandir
Installing collected packages: contextlib2, zipp, configparser, scandir, six, pathlib2, importlib-metadata, typing, singledispatch, importlib-resources, filelock, appdirs, distlib, virtualenv
Successfully installed appdirs-1.4.3 configparser-4.0.2 contextlib2-0.6.0.post1 distlib-0.3.0 filelock-3.0.12 importlib-metadata-1.6.0 importlib-resources-1.4.0 pathlib2-2.3.5 scandir-1.10.0 singledispatch-3.4.0.3 six-1.14.0 typing-3.7.4.1 virtualenv-20.0.18 zipp-1.2.0

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