Search code examples
pythonpipcommand-linepackagepython-2.6

Install pip on Python 2.6


I need to install pip on Python 2.6. I have tried a couple of solutions available.

Commands used:

curl https://bootstrap.pypa.io/pip/2.6/get-pip.py -o get-pip.py

Output

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1719k  100 1719k    0     0  1860k      0 --:--:-- --:--:-- --:--:-- 1860k

And:

python get-pip.py

Output

  Traceback (most recent call last):
  File "get-pip.py", line 22123, in <module>
    main()
  File "get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\__init__.py", line 43, in <module>
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\utils\__init__.py", line 22, in <module>
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\compat\__init__.py", line 24, in <module>
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\_vendor\ipaddress.py", line 1683, in <module>
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\_vendor\ipaddress.py", line 1685, in _IPv4Constants
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\_vendor\ipaddress.py", line 1625, in __init__
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\_vendor\ipaddress.py", line 1399, in __init__
  File "c:\users\faz\appdata\local\temp\tmprxjgud\pip.zip\pip\_vendor\ipaddress.py", line 553, in _check_packed_address
pip._vendor.ipaddress.AddressValueError: '169.254.0.0/16' (len 14 != 4) is not permitted as an IPv4 address. Did you pass in a bytes (str in Python 2) instead of a unicode [sic] object?

Is pip still supported with Python 2.6?


Solution

  • For Python 2.6 you need older setuptools. The last setuptools version that works with Python 2.6 is 36.8.

    Download setuptools-36.8.0.zip, unpack, cd into the extracted directory and run python2.6 setup.py install (python.exe setup.py install on Windows).

    The last version of pip supporting Python 2.6 is 9.0.3: https://pypi.org/project/pip/9.0.3/#files

    Download pip-9.0.3.tar.gz, unpack, cd into the extracted directory and run python2.6 setup.py install (python.exe setup.py install on Windows).

    I tested the process though it was hard — I failed to install Python 2.6 with conda or pyenv, no luck with Debian 6 in Docker. Finally I managed to run a VM in emulator QEMU, installed Python 2.6, setuptools and pip.

    Locally the installed pip works but it cannot connect to PyPI because Python 2.6 is linked with ancient OpenSSL and cannot connect over HTTPS protocol to pypi.org. So for any package you need to download source or wheel distributions (including all dependencies) manually and run pip with option --no-index to disable access to PyPI.