Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install pip with Python 2 needs documentation update #9577

Closed
1 task done
gitclem opened this issue Feb 9, 2021 · 9 comments
Closed
1 task done

Install pip with Python 2 needs documentation update #9577

gitclem opened this issue Feb 9, 2021 · 9 comments
Labels
good first issue A good item for first time contributors to work on type: docs Documentation related

Comments

@gitclem
Copy link

gitclem commented Feb 9, 2021

pip version

20.3.4

Python version

2.7.16

OS

Mac OS 10.15.7

Additional information

No response

Description

On page:
https://pip.pypa.io/en/stable/installing/

It says to install pip, use:

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

This does not work on Python 2.7. You get the Python error:

python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 24244, in
main()
File "get-pip.py", line 199, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
from pip.internal.cli.main import main as pip_entry_point
File "/var/folders/k
/blmzttsn5m35fd86smzys36h0000gp/T/tmpFuDDh2/pip.zip/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")

The correct way to install pip on Python 2 is:

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

and then
python get-pip.py

Expected behavior

pip for Python 2.7 should install without errors

How to Reproduce

  1. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  2. python get-pip.py # using python 2.7
  3. An error occurs because python2.7 doesn't understand formatted strings of python 3.7: f""

Output

python get-pip.py
Traceback (most recent call last):
  File "get-pip.py", line 24244, in <module>
    main()
  File "get-pip.py", line 199, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "/var/folders/k_/blmzttsn5m35fd86smzys36h0000gp/T/tmpFuDDh2/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")

Code of Conduct

  • I agree to follow the PSF Code of Conduct

Either the get-pip.py should be made to run with either version of Python OR the documentation ( https://pip.pypa.io/en/stable/installing/ ) needs updating.

@gitclem gitclem added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Feb 9, 2021
@pfmoore
Copy link
Member

pfmoore commented Feb 9, 2021

https://pip.pypa.io/en/stable/installing/#python-and-os-compatibility

Pip no longer supports Python 2.

@gitclem
Copy link
Author

gitclem commented Feb 9, 2021

https://pip.pypa.io/en/stable/installing/#python-and-os-compatibility

Pip no longer supports Python 2.

Well, the documentation should say that. But in any case what I did, does work, so that should be documented.

I do think it’s important to support 2.7 as much as possible because some OS tools still use 2.7 (eg the Mac). For my work, I’ve moved over to 3.x except I’m having an awful time with installing pylucene so I’m trying 2.7 and it’s almost working whereas 3.x dies in ways that I don’t understand.

@pradyunsg
Copy link
Member

Well, the documentation should say that.

@pfmoore linked you to pip's documentation. Could you clarify what more you want the documentation to say?

Would a dedicated section talking about Python 2 support help? We have that too: https://pip.pypa.io/en/stable/development/release-process/#python-2-support

@pradyunsg pradyunsg added resolution: no action When the resolution is to not do anything S: awaiting response Waiting for a response/more information type: docs Documentation related and removed S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Feb 9, 2021
@gitclem
Copy link
Author

gitclem commented Feb 10, 2021

Well, the documentation should say that.

@pfmoore linked you to pip's documentation. Could you clarify what more you want the documentation to say?

Would a dedicated section talking about Python 2 support help? We have that too: https://pip.pypa.io/en/stable/development/release-process/#python-2-support

I thought I made it clear. On page:
https://pip.pypa.io/en/stable/installing/

The paragraph entitled "Installing with get-pip.py" says:

To manually install pip, securely 1 download get-pip.py by following this link: get-pip.py. Alternatively, use curl:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then run the following command in the folder where you have downloaded get-pip.py:
Unix/macOS
python get-pip.py

This section says nothing about this being for 3.x only. If you try to follow the instructions, you get an error about the 3.x python formatted string f"ERROR: {exc}"

I get that the world is moving away from 2.7 to 3.x. I'm using 3.x myself and get annoyed whenever I have to deal with 2.7

The problem is, a lot of old OS tools (e.g. on the Mac) depend on Python 2.7, and that's not going to get fixed any time soon.

Add extra disclaimers about 3.x or pointers to 2.7 pip would help a person not get lost in the weeds as to what was wrong.

@no-response no-response bot removed the S: awaiting response Waiting for a response/more information label Feb 10, 2021
@pradyunsg
Copy link
Member

That page clearly states:

The get-pip.py script is supported on the same python version as pip.

We can probably remove the Python 2.6 link and have a better sentence to direct users to the right place tho.

@pradyunsg pradyunsg added good first issue A good item for first time contributors to work on and removed resolution: no action When the resolution is to not do anything labels Feb 10, 2021
@gitclem
Copy link
Author

gitclem commented Feb 10, 2021

That page clearly states:

The get-pip.py script is supported on the same python version as pip.

We can probably remove the Python 2.6 link and have a better sentence to direct users to the right place tho.

Let me point out that other people have stumbled over this problem, so it's not just me who find the instructions not clear enough:

https://stackoverflow.com/questions/65866417/pip-install-failing-on-python2

@devilmen80
Copy link

Yes me too. But with this command pip2 will be installed and will not entry in conflict with pip3?

@gitclem
Copy link
Author

gitclem commented Feb 11, 2021

Yes me too. But with this command pip2 will be installed and will not entry in conflict with pip3?

It shouldn't... On my mac:

which pip3
/usr/local/bin/pip3
which pip2
/usr/local/bin/pip2
which pip
/Users/user/Library/Python/2.7/bin/pip

On the other hand, my pip2 got mangled some how and it died because it had the formatted f"" python 3.x string. I just fixed it. And like I said, my Mac OS X 10.15.7 uses Python 2.7 for its system stuff. I use pyenv for my 3.8 work.

@pradyunsg
Copy link
Member

This should be resolved by pypa/get-pip#100.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue A good item for first time contributors to work on type: docs Documentation related
Projects
None yet
Development

No branches or pull requests

4 participants