Pip: can't install pip in Python 2.6.* by using get-pip.py

Created on 20 Mar 2018  路  21Comments  路  Source: pypa/pip

  • Pip version: maybe 9.0.2
  • Python version: 2.6.6
  • Operating system: macOS 10.13.3

Description:

I've installed python 2.6.6 from source code and I tried to install pip using get-pip.py downloaded drom https://bootstrap.pypa.io/get-pip.py
However, it cannot be installed because of the following error:

Traceback (most recent call last):
  File "get-pip.py", line 22373, 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 "/path/pip.zip/pip/__init__.py", line 34, in <module>
AttributeError: 'module' object has no attribute 'OPENSSL_VERSION_NUMBER'

As you may know, OPENSSL_VERSION_NUMBER is introduced to python at 2.7, so actually the following part won't work:
https://github.com/pypa/pip/blob/master/src/pip/_internal/__init__.py#L27-L39

Actually I found it when I tried to install python 2.6.6 by using pyenv. If you have already not supported these versions, I think I have to let the developers of pyenv know these bug because currently we cannot at all install python 2.6.* by using pyenv.

So, I want to ask pip developers:
First of all, Is this a bug of pip-side? If not, do you think that it is a correct way to fix or adjust pyenv-side?


I found Installation Guide said:

Python and OS Compatibility
pip works with CPython versions 2.6, 2.7, 3.3, 3.4, 3.5 and also pypy.

Therefore I think it is not reasonable that we cannot install python 2.6.

auto-locked

Most helpful comment

I was able to resolve this by pointing it at the version of get-pip.py in this commit to pypa/get-pip from 2016:

$ export GET_PIP_URL=https://github.com/pypa/get-pip/raw/430ba37776ae2ad89f794c7a43b90dc23bac334c/get-pip.py

$ pyenv install 2.6.9
python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-2.6.9...
patching file setup.py
Hunk #1 succeeded at 354 (offset 9 lines).
patching file ./configure
patching file ./Modules/readline.c
Hunk #1 succeeded at 199 (offset -7 lines).
Hunk #2 succeeded at 698 (offset -51 lines).
Hunk #3 succeeded at 808 (offset -51 lines).
Hunk #4 succeeded at 848 with fuzz 2 (offset -70 lines).
patching file ./setup.py
Hunk #1 succeeded at 1698 (offset 23 lines).
patching file ./Lib/ssl.py
patching file ./Modules/_ssl.c
python-build: use readline from homebrew
Installing pip from https://raw.githubusercontent.com/pypa/get-pip/430ba37776ae2ad89f794c7a43b90dc23bac334c/get-pip.py...
Installed Python-2.6.9 to /Users/di/.pyenv/versions/2.6.9

$ python2.6 --version
Python 2.6.9

All 21 comments

pip 10 will not support Python 2.6 (see the new version of the Installation Guide). Unfortunately, 9.0.2 was released with an emergency backport of a pip 10 feature that is needed to ensure that Mac OS users who are using the system Python can still access PyPI, and the backported code isn't Python 2.6 compatible.

To use pip on Python 2.6, you'll need to stick to version 9.0.1. Apologies for the confusion - this change would not normally have happened in a minor release.

I actually experienced the same issue today, it's making it difficult for me to maintain projects which do still support Python 2.6 because I can no longer pyenv install 2.6.x, and no amount of pointing the build at OpenSSL seems to resolve it.

It looks like pyenv supports setting GET_PIP_URL to something other than https://bootstrap.pypa.io/get-pip.py but it's not really clear to me where else I could point it to get the 9.0.1 version of get-pip.py.

I was able to resolve this by pointing it at the version of get-pip.py in this commit to pypa/get-pip from 2016:

$ export GET_PIP_URL=https://github.com/pypa/get-pip/raw/430ba37776ae2ad89f794c7a43b90dc23bac334c/get-pip.py

$ pyenv install 2.6.9
python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-2.6.9...
patching file setup.py
Hunk #1 succeeded at 354 (offset 9 lines).
patching file ./configure
patching file ./Modules/readline.c
Hunk #1 succeeded at 199 (offset -7 lines).
Hunk #2 succeeded at 698 (offset -51 lines).
Hunk #3 succeeded at 808 (offset -51 lines).
Hunk #4 succeeded at 848 with fuzz 2 (offset -70 lines).
patching file ./setup.py
Hunk #1 succeeded at 1698 (offset 23 lines).
patching file ./Lib/ssl.py
patching file ./Modules/_ssl.c
python-build: use readline from homebrew
Installing pip from https://raw.githubusercontent.com/pypa/get-pip/430ba37776ae2ad89f794c7a43b90dc23bac334c/get-pip.py...
Installed Python-2.6.9 to /Users/di/.pyenv/versions/2.6.9

$ python2.6 --version
Python 2.6.9

Same problem here, and now py26 in tox (and also python2.6 virtualenv) is simply broken.

$ pip
Traceback (most recent call last):
  File "/Users/user/.virtualenvs/py26-test/bin/pip", line 7, in <module>
    from pip import main
  File "/Users/user/.virtualenvs/py26-test/lib/python2.6/site-packages/pip/__init__.py", line 34, in <module>
    ssl.OPENSSL_VERSION_NUMBER < 0x1000100f):  # OpenSSL 1.0.1
AttributeError: 'module' object has no attribute 'OPENSSL_VERSION_NUMBER'

@pfmoore
In certain tools like virtualenv, tox, there is no configurable way to specify pip version...

@pfmoore
@di
@Happyholic1203

Thank you for the replies.
I think it would be better to add an instruction like @di 's comment to install pip for 2.6.*.
https://github.com/pypa/pip/issues/5093#issuecomment-374779915

@pfmoore
IMO, If you need it, you'd better to upload another get-pip.py which is compatible with python 2.6 as soon as possible.

IMO, If the future pip does not support python 2.6, it might be a bit difficult to merge #5097 , but thank you for the work @Happyholic1203

5097 will probably apply cleanly to the 9.0.2 branch. @dstufft might want to consider it for a possible 9.0.3 to restore support for Python 2.6 on the 9.0.* branch.

According to https://pip.pypa.io/en/latest/installing/ there should be a 2.6-compatible version of get-pip.py at https://bootstrap.pypa.io/2.6/get-pip.py. That link doesn't seem to exist though. @dstufft do you know who manages bootstrap.pypa.io and how we get a suitable get-pip up there?

Yea I'll pull this (or something like it) into 9.0.3 when I make it. WRT the 2.6 get-pip.py, @ewdurbin might be the best to look at it right now.

looks like the salt-states for bootstrap don't bother with the 2.6 thing, that can be resolved shortly.

Note: That probably won't work right now, because 9.0.2 wasn't intended to break 2.6 compatibility, so it generated 2.6/get-pip.py with 9.0.2.

@dstufft should I do another get-pip release that rolls that back?

Nah, I'll try to get a 9.0.3 out sometime today.

@ewdurbin Fantastic, thanks. @dstufft When I release pip 10, I'll regenerate get-pip.py. Will I need to do anything special to not overwrite the 2.6-compatible version?

Brilliant :-)

So pyenv should always be looking at https://bootstrap.pypa.io/2.6/get-pip.py when installing 2.6 (or https://bootstrap.pypa.io/3.2/get-pip.py for 3.2, it seems), right?

Yea.

This is fixed in pip 9.0.3 and get-pip.py will be updated shortly.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings