Search code examples
pythonpipportable-applications

How to update pip and keep the new version of pip portable (=use relative path to python.exe)?


I use WinPython as portable app on Windows and get following hint:

A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: python.exe -m pip install --upgrade pip

If I run the command as suggested, the new version of pip stores the absolute path to python.exe.

If I move my IDE folder to another location, pip does not work any more:

pip list
Fatal error in launcher: Unable to create process using '"C:\python_env\App\WinPython\python-3.11.1.amd64\python.exe"  "D:\eis\python_env\App\WinPython\python-3.11.1.amd64\Scripts\pip.exe" list': The system cannot find the file specified.

=> Is there a way to tell pip to store a relative path to python.exe instead of an absolute one, so that pip remains portable?

=> Or is there some configuration file that I could fix after installing pip, for example some pip._pth file? Where to put it?


Solution

  • WinPyton comes with a script file that fixes portability:

    WinPython/scripts/make_winpython_movable.bat