0

When I install a package via pip (on Windows), e.g. pip, one or more Windows executables are created in the scripts directory.

> PowerShell -NoProfile -ExecutionPolicy -Command "Invoke-WebRequest -Uri 'https://bootstrap.pypa.io/get-pip.py' -OutFile 'get-pip.py'" 
> python get-pip.py

Collecting pip
  Using cached pip-21.2.4-py3-none-any.whl (1.6 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.2.4
    Uninstalling pip-21.2.4:
      Successfully uninstalled pip-21.2.4
Successfully installed pip-21.2.4

> dir ..\python-3.8.5\scripts\pip*.exe
 Volume in drive C has no label.
 Volume Serial Number is 1837-4411

 Directory of \python\python-3.8.5\scripts

09/30/2021  08:18 AM            97,151 pip.exe
09/30/2021  08:18 AM            97,151 pip3.8.exe
09/30/2021  08:18 AM            97,151 pip3.exe
09/29/2021  03:52 PM            97,093 pipdeptree.exe
               4 File(s)        388,546 bytes

pip.exe, pip3.exe, and pip3.8.exe all look to be something kind of py2exe-ish with a Python script embedded in the executable.

What is auto-creating these executables?

The embedded script uses a shebang that has a hardcoded path to the python executable. What I intend as a portable Python distribution is being hosed by this hardcoded path (rather than just specifying python without a path).

Details which may or may not matter

Is there a way to tell pip (or whatever is creating these wrapped executables) to behave differently in this regard?

7
  • Your question is not clear, do you want to make portable your python interpreter with its packages and executables Commented Sep 30, 2021 at 17:13
  • I have a portable installation. I update packages with pip. It's no longer portable. I want to be able able to update/install packages and keep it portable. Commented Sep 30, 2021 at 17:40
  • The question remains that I want to control the generation of these executables (or at least know who/how they're being generated). Commented Sep 30, 2021 at 17:43
  • If you want your packages to be installed for a specific python version, you can install that using: your\particular\python -m pip install some_package Commented Sep 30, 2021 at 17:55
  • The version is not the issue. It's the "location" of python that creates problems. The absolute path to python.exe is hardcoded into script embedded in the .exe. Where's the exe coming from? That's (the beginning) of the answer to my question. Commented Sep 30, 2021 at 19:37

1 Answer 1

1

These files are created using py2exe whose configurations can be found in setup.py file of the project.

Refer this link for more information: https://python101.pythonlibrary.org/chapter40_py2exe.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.