Ship pip as a standalone application
See original GitHub issueActually, it occurred to me that we may even be able to do this right now. I put together a very simple proof of concept and it seems to work. If you put the following script alongside a “lib” directory with pip installed into it (pip install pip --target lib) but with the bin and pip*.dist-info directory removed (so the bundled pip isn’t visible in pip list) then it can be run from any Python interpreter to effectively act as a copy of pip in that environment.
#!/usr/bin/env python
import runpy
import sys
import os
lib = os.path.join(os.path.dirname(__file__), "lib")
sys.path.insert(0, lib)
runpy.run_module("pip", run_name="__main__")
I don’t think it would take much to turn this into a viable “standalone pip” application (I’d mostly just want to set up an executable wrapper for Windows). I’ve done some very basic testing - this would need a lot more real-world testing to make sure there aren’t any problem edge cases, but it basically seems to work.
_Originally posted by @pfmoore in https://github.com/pypa/pip/issues/11223#issuecomment-1179518843_
For now, this is just a placeholder to discuss whether we want to do this at all, or how we’d distribute it. The main point here is that with a script like this, there would no longer be a need to install pip in every virtual environment.
One thing we’d have to work out is what tools assume that pip is available in every environment. I’m thinking of environment managers and IDEs, like nox, or VS Code. The ecosystem implications here are likely to be more complicated than the technical issues. Maybe we need to start with a heads-up discussion on Discourse? But before we do that I’d like to make sure the pip committers are all on board with the idea…
Issue Analytics
- State:
- Created a year ago
- Comments:41 (41 by maintainers)

Top Related StackOverflow Question
For what it’s worth, I’ve just created https://github.com/pfmoore/runpip
The build script is there, and I’ve published a 22.1.2 release that has the pyz as a downloadable asset. If people want to play with it, go ahead. I think I’m going to make it my default pip locally and see how that works out.
While we are brainstorming, something comes to my mind… would it make any sense for
ensurepip(or python -m venv?) to install pip by placing a.pthin the target environment (pointing to the wheel, a zip, or an unpacked copy of pip) ? That wouldpython -m pippipscripts