What to do when “Python” cannot be executed in Windows PowerShell

自動翻訳(Auto Translation)

Memorandum for when you can’t run Python even after installing “Python” in PowerShell on Windows.

I can’t run Python.

After installing Python, typing “Python –version” in PowerShell may display “Python” and fail to run.

PowerShellPS
C:Windowssystem32> Python --version
Python
PS C:Windowssystem32>

Case 1: No environment variables have been added.

When Python is installed, there is an item to select whether to add environment variables, but if this item is not selected, it cannot be used with “PowerShell”.

(The checkbox is unchecked by default.)

How to add additional environment variables after installation

If you want to add an environment variable again after installing Python once, you can do so by setting it as follows.

Launch the “Python Installer” in an environment where Python has already been installed.
Select “Next” without selecting anything in the Optional Featuer.
Check “Add Python to environment variables” and select “Install”.

Python is now ready to use.

    この記事は役に立ちましたか?


    Case 2: If the standard Windows Python is running

    Since Python is installed by default in Windows (or more precisely, the Python installer), Python may fail to start if it is given priority.

    In this case, you may be able to solve the problem by disabling standard Python from the Windows Settings app.

    Select “Apps” from the Settings app.

    Select “App Execution Alias” from “Apps & Features
    Disable the “Python” related checkboxes from the App Execution Alias.

    This is the solution to the problem of not being able to run “Python” in PowerShell.

    Please share this article if you like.

      この記事は役に立ちましたか?


      広告ブロック機能を検知しました

      このウェブサイトは広告収益によって成り立っています。ご協力をお願いします。