pypa / get-pip

Helper scripts to install pip, in a Python installation that doesn't have it.
https://bootstrap.pypa.io/pip/
MIT License
755 stars 297 forks source link

Unable to create compliant pip installation on windows #163

Closed hohwille closed 1 year ago

hohwille commented 2 years ago

get-pip supports --prefix option what is great. I wanted to use it to install pip into an own pip folder alongside python folder. This creates a pip installation with the desired structure having a bin folder also on Windows avoiding cross-platform incompatibilities. However, the resulting pip installation does not work:

$ pip --version
Traceback (most recent call last):
  File "runpy.py", line 196, in _run_module_as_main
  File "runpy.py", line 86, in _run_code
  File "D:\projects\devonfw\software\python\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

If you have any hint or solution to this problem you would do us a great favor as we want to integrate python and pip into devonfw-ide to make it available easier and create a seamless automated installation for all platforms. Unfortunately Python and pip are giving us an extraordinary hard time to make this happen.

Related issues:

pradyunsg commented 2 years ago

Hiya!

I wanted to use it to install pip into an own pip folder alongside python folder.

You can't do that. The way that the Python interpreter works is that certain locations are the default import paths for it -- only those paths are used in locating a <packagename> in import <packagename>.

By using --prefix, you're dumping pip's file in an arbitrary location -- a location that may not be on the import paths for the interpreter.

The solution here is to not try to use --prefix and to instead ship pip as a part of site-packages in Python. That's the default behaviour of doing a pip install as well as get-pip.py and I suggest you stick to that.