Windows powershell starts old python

XeniaSophieKatharinaStibane-5237 20 Reputation points
2023-07-18T18:34:01.2266667+00:00

Hello together,

this is what I get if I try to start my new installed python 3.11.4:

PS C:\Users\XXX> python

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

Any ideas?

Greetings

Windows for business Windows Server User experience PowerShell
{count} votes

Accepted answer
  1. Limitless Technology 44,746 Reputation points
    2023-07-19T12:22:18.44+00:00

    Hello Xenia,

    Thank you for your question and for reaching out with your question today.

    Based on the information provided, it seems like you have both Python 3.11.4 and Python 3.7.4 installed on your system, and when you run the python command in PowerShell, it is invoking Python 3.7.4 instead of the newly installed Python 3.11.4.

    To run Python 3.11.4 in your PowerShell, you can try the following:

    1. Use the Full Path: Instead of just running python, specify the full path to the Python 3.11.4 executable. The exact path may vary based on your installation, but it should be something like:
      
         PS C:\Users\XXX> C:\path\to\python3.11.4\python
      
      
    2. Check Environment Variables: Ensure that the environment variable for the Python 3.11.4 installation is set correctly. The PATH environment variable should include the path to the Python 3.11.4 executable directory. You can check this by running:
      
         PS C:\Users\XXX> $env:PATH
      
      
      If the Python 3.11.4 path is missing, you can add it using the following command (replace C:\path\to\python3.11.4 with the actual path):
      
         PS C:\Users\XXX> $env:PATH += ";C:\path\to\python3.11.4"
      
      
    3. Check File Associations: On Windows, the file association for .py files determines which version of Python is used when running scripts without specifying the version. Ensure that Python 3.11.4 is associated with .py files. You can check this in the "Default apps" settings or use the ftype command in PowerShell:
      
         PS C:\Users\XXX> ftype Python.File
      
      
      If it is not associated correctly, you can set it using the following command (replace C:\path\to\python3.11.4\python.exe with the actual path):
      
         PS C:\Users\XXX> ftype Python.File="C:\path\to\python3.11.4\python.exe" "%1" %*
      
      

    After making any changes, close and reopen your PowerShell window to apply the changes. Now, when you run python, it should invoke Python 3.11.4 instead of the older version.

    Note: If you are planning to use Python 3.11.4 more frequently, you might consider uninstalling the older version (Python 3.7.4) to avoid potential conflicts and ensure that your default Python version is the latest one.

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    If the reply was helpful, please don’t forget to upvote or accept as answer.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. XeniaSophieKatharinaStibane-5237 20 Reputation points
    2023-07-19T14:07:17.39+00:00

    Dear Rich and Limitless Technology, thank you very much, yes it was a Path-Problem!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.