question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecate pip, pipX, and pipX.Y

See original GitHub issue

Currently, people are regularly running into problems over confusion about which particular Python a particular invocation of pip is going to manage. There are many cases where what Python a particular invocation of pip* is going to invoke is unclear:

  • pip3 install --upgrade pip will overwrite pip and possibly switch it from pointing to 2.7 to 3.5.
  • pip3 isn’t specific enough, you might have 3.4 and 3.5 installed.
  • pip3.4 isn’t specific enough, you might have 3.4.0 and 3.4.1 installed.
  • pip3.4.0 isn’t specific enough, you might have multiple copies of 3.4.0 installed in various locations.
  • We don’t have a good answer for what the pip binary should be called on alternative Python interpreters like PyPy (pip-pypy? What if we have two versions of PyPy? pip-pypy2.6? What if we have PyPy and PyPy3? pip-pypy-2.6 and pip-pypy3-2.6?).

Overall, it’s become increasingly clear to me that this is super confusing to people. Python has a built in mechanism for executing a module via python -m. I think we should switch to using this as our preferred method of invocation. This should completely eliminate the confusion that is caused when python and pip don’t point to the same version of Python, as well as solve the problem of what do you call the binary on alternative implementations.

In addition to the confusion, we also have the fact that pip install --upgrade pip doesn’t actually work on Windows because of problems with the .exe file being open. However python -m pip install --upgrade pip does work there.

I see only three real downsides:

  • There is a lot of documentation, examples, code or other instances of inertia using just pip and this will be churn for those.
  • It’s 10 more letters to type.
  • It doesn’t work on Python 2.6.

For the first of these, I think the answer is to just have a very long deprecation cycle, in the order of years. I wouldn’t even put a specific date on it’s removal, I’d just add the warnings and re-evaluate in the future. Luckily we’ve shipped support for python -m pip for quite some time, so it won’t be something that people need to deal with version differences (mostly).

The second of these I don’t really have a great answer for, I think that 10 extra letters probably isn’t that big of a cost to pay for the reduced confusion and the default answer working on Windows. We could possibly offer a recipe in the docs to restore pip, pipX, and pipX.Y via shell aliases.

This last item is the biggest sticking point for me. As far as I know, Python 2.6 still has far too many users for us to drop it since, as of 6 months ago, it was still ~10% of the traffic on PyPI (source). The problem with Python 2.6 is that it only supports -m when the target is a module not a package. I see four possible solutions to this:

  • Don’t deprecate pip* on Python 2.6.
  • Add a module like pipcli.py that people can invoke like python -m pipcli instead of python -m pip.
  • Move pip/ to _pip/ and make pip.py.
  • Document that due to limitations of Python 2.6, it will need to be invoked as python -m pip.__main__.

I don’t really like the pipcli idea, the other three all have pros and cons, but I think I personally live with either not deprecating pip* on Python 2.6 and/or documenting that it needs to be invoked as ``python -m pip.main on Python 2.6).

What do the @pypa/pip-developers think?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:22
  • Comments:125 (92 by maintainers)

github_iconTop GitHub Comments

3reactions
dstufftcommented, Mar 11, 2022

FWIW, I still think that python -m pip is the wrong way to go about things, and we should instead add -p to pip and allow it to target other environments. We could then in theory enable people not to have 12742345 different copies of pip installed all different versions.

2reactions
pradyunsgcommented, Mar 11, 2022

I mean, if one of our primary concerns is that users get confused when plain pip does not match python / pipX does not match pythonX, we could just… start checking for that and warning about it – eventually changing that to a failure?

@dstufft Where would the “central” pip installation live then? I mean, we could totally make pip into a zipapp – I’d be fine with that – but it’s not clear to me how we’d migrate to something like that; such that they don’t have 12 million pip copies on disk. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docs - pipx
Virtual Environments will be installed to $PIPX_HOME/venvs. ... Runs `pip install -U <pkgname>` for each package. uninstall Uninstall a package ...
Read more >
Changelog - pip documentation v22.3.1
Fix entry point generation of pip.X , pipX.Y , and easy_install-X.Y to correctly account for multi-digit Python version segments (e.g. the “11” part...
Read more >
Simplify Your Python Developer Environment
Three tools ( pyenv , pipx , pipenv ) make for smooth, isolated, reproducible Python developer and production environments. Using pyenv with ...
Read more >
Setting the path / Directory lookup for Pipx (Python 3.9 / ...
I've tried this and it works for me: Uninstall pipx using pip: pip uninstall pipx and to completely remove pipx, u need to...
Read more >
pip-tools 6.12.1
Y -m piptools compile on other systems. pip-compile should be run from the same virtual environment as your project so conditional dependencies that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found