0

I have several versions of Python installed on my system, and a software I use requires using Python3.11, the problem is that the most recent version of Python is the one Windows defaults to, i.e. if I type ‘py’ in the terminal, it automatically starts Python3.12.3, and I would like to start the program with Python3.11.9.

I tried to do it as it would be done in Linux, (python3.11 .\main.py) but it just doesn't recognise the ‘Python3.11’ command.

How do I do this?

PS: All the Python installations are added to the path, the problem is that the executable is named the same in all of them "python.exe", so when I run "py" or "python" in the console, it just takes the latest version by default as I said.

2
  • but it just doesn't recognise the ‘Python3.11’ command ... the Python3.11 is probably an alias in Linux ... try using a Windows shortcut
    – jsotola
    Commented Jun 3 at 18:37
  • You need to change the order in the PATH environment variable to put version 3.11.9 first.
    – harrymc
    Commented Jun 3 at 18:46

1 Answer 1

0

You could use a virtual environment and set the python version you want to use in it using python<version> -m venv <envname>. This way the packages you want to install for running that particular program can also be isolated from interfering with the global packages. More info on that can be found here: https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv

1
  • 1
    This seems like a heavy solution for a person that needed a simple path re-organization. Commented Jun 3 at 22:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .