1

The Windows 8.1 PC I'm working on has several Pythons installed in different locations (as indicated by py -0p). Most of them are to be considered unreliable: their versions are changed, they get deleted, configured and added. One of the Pythons is mine, and I'd like to set it's location as the default on the PC without prohibiting access to other Pythons.
At least, I'd like for py to launch Python from the specific location regardless of versions and other Pythons.


Troubles with the tools I've found:

  • changing PATH doesn't affect the py command
  • py.ini (as far as I'm aware) only allows version selection and not path selection
  • the same goes for PY_PYTHON
  • deleting other Pythons will solve the problem only temporarily (and also be very rude)
  • shebang doesn't change the default version and may lead to an unreliable Python
  • venv seems to be clunky: I would like to use python with minimal setup each time

I was asked to provide the results of something like py -0p. Here they are, but bear in mind, that this list is not stable and is usually changing

Installed Pythons found by py Launcher for Windows                                                                                                      
 -3.9-64        C:\Program Files (x86)\...\Python39_64\python.exe *                                                          
 -3.8-64        C:\Program Files\Python38\python.exe 
10
  • Note that Windows 8.1 hit EOL in January of 2023. It's a dead operating system, and giant security vulnerability. Commented Jul 7 at 22:31
  • You could write a py.bat or Powershell script that does what you want and set its location as the first in PATH. Commented Jul 7 at 22:33
  • py shouldn't be affected by your path. The other things you say don't make much sense and aren't in line with how py is supposed to work. docs.python.org/3/using/windows.html#launcher Can you provide more details - what actually happens, what python executables are used, where are they? I'd stick to the use case you want to use rather than worry about all the possibilities (i.e., I want to use this python but I am getting that python when I do such and such). Also fwiw feel free to go ahead and be rude and remove the unreliable (unsupported?) pythons.
    – topsail
    Commented Jul 7 at 22:38
  • 1
    You say py.ini only allows version selection, but not path selection. Are you implying that you have multiple copies of the same version of Python installed? That would make some sense in the context of virtual environments, but py is mostly useful for managing access to global environments for Python. You don't want to use virtual environment copies without activating the virtual environment and when you do, you'd use python and not py?
    – Grismar
    Commented Jul 7 at 23:18
  • @topsail I've read the docs and just wanted to avoid unhelpful answers. Other Pythons are not unsupported — other users of the PC meddle with them (yes) in many ways, and I want to use vanilla Python. Also, I'm not sure if specific file paths would be useful, since they change constantly (except for py.exe's and my Python's)
    – multus
    Commented Jul 8 at 11:24

0

Browse other questions tagged or ask your own question.