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 thepy
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
py.bat
or Powershell script that does what you want and set its location as the first inPATH
.py
shouldn't be affected by your path. The other things you say don't make much sense and aren't in line with howpy
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.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, butpy
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 usepython
and notpy
?py.exe
's and my Python's)