Python was not found; run without arguments to install from the Microsoft Store

avatar
Borislav Hadzhiev

Last updated: Apr 10, 2024
6 min

banner

# Python was not found; run without arguments to install from the Microsoft Store

The error "Python was not found; run without arguments to install from the Microsoft Store" occurs for 2 main reasons:

  1. Not having the path to Python in your user's PATH environment variable.
  2. Not having Python installed on your machine.

python was not found run without arguments to install

cmd
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App execution Aliases. Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640

A quick fix you should try is to use the py alias instead of python when issuing commands.

PowerShell
# ๐Ÿ‘‡๏ธ Get the version py --version # ๐Ÿ‘‡๏ธ Start Python interpreter py # ๐Ÿ‘‡๏ธ Exit Python interpreter exit() # ๐Ÿ‘‡๏ธ Install a Python package py -m pip install numpy # ๐Ÿ‘‡๏ธ Run a Python script py my_script.py

using py alias instead of python

If you have multiple Python versions installed, you can use a hyphen to specify which version the py command relates to, for example, py -2, py -3 or py -3.10.

You can use the py -0 command to check which Python versions are installed on your machine.
cmd
py -0

which python versions are installed

The screenshot shows that my active Python version is 3.10, but I also have 3.9 installed.

Here are examples of issuing py commands scoped to Python 3.9.

cmd
# ๐Ÿ‘‡๏ธ Print Python 3.9 version py -3.9 --version # ๐Ÿ‘‡๏ธ Start Python 3.9 interpreter py -3.9 # ๐Ÿ‘‡๏ธ Exit interpreter exit() # ๐Ÿ‘‡๏ธ Install package using Python 3.9 py -3.9 -m pip install requests

py command scoped to version

# Making sure your IDE is using the correct Python version

If you have multiple Python versions installed on your machine, your IDE might be using an incorrect version.

For example, In VS Code, you can press CTRL + Shift + P or (โŒ˜ + Shift + P on Mac) to open the command palette.

Then type "Python select interpreter" in the field.

python select interpreter

Then select the correct Python version from the dropdown menu.

select correct python version

Your IDE should be using the same version of Python (including the virtual environment) that you are using to install packages from your terminal.

If the error is not resolved, you have to add the path to Python and pip to your PATH environment variable.

# Add the path to Python to your user's PATH environment variable

To add the path to Python to your user's PATH environment variable:

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "User variables for YOUR_USER" section, select the "Path" variable and click "Edit".

select user path click edit

  1. Click on "New" and then click "Browse".

click new browse

  1. You can use one of the following commands to check where your Python installation is located.
cmd
py -c "import os, sys; print(os.path.dirname(sys.executable))" python -c "import os, sys; print(os.path.dirname(sys.executable))" where python

find python path

For me, the path is the following.

cmd
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310

Note that I have Python 3.10 installed, which is reflected in the PATH.

  1. Add the path to Python and then add the path to the Scripts directory that is located in your Python3X folder.

    This is where the executable files are located, including pip.exe.

For me, it is the following path.

cmd
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\Scripts

add scripts folder

  1. Once the two paths are added, confirm the changes by clicking on the "OK" button twice.

added python and pip to path

  1. Close your Command prompt application and your Power Shell session and then reopen your shell.
Note that you must restart Command Prompt, Power Shell and your IDE for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

Try to issue a python command in a new shell session.

PowerShell
# ๐Ÿ‘‡๏ธ Get version python --version # ๐Ÿ‘‡๏ธ Start Python interpreter python # ๐Ÿ‘‡๏ธ Exit Python interpreter exit() # ๐Ÿ‘‡๏ธ Install your Python package python -m pip install numpy # ๐Ÿ‘‡๏ธ Run a Python script python my_file.py

python command works

If you still get the error, you have to disable the Python App installer in "App execution aliases".

# Disable Python App installer in App execution aliases

  1. Click on the Search bar and type "Manage app execution aliases".

search manage app exeucution aliases

  1. Locate the App installers for python.exe and python3.exe and disable them as shown in the screenshot below.

disable python app installer

Once done, restart all Command Prompt applications, PowerShell and IDE sessions and try to issue the python --version command.

If the error persists, try using py instead of python.

PowerShell
# ๐Ÿ‘‡๏ธ Get version py --version # ๐Ÿ‘‡๏ธ Start Python interpreter py # ๐Ÿ‘‡๏ธ Exit Python interpreter exit() # ๐Ÿ‘‡๏ธ Install your Python package py -m pip install numpy # ๐Ÿ‘‡๏ธ Run a Python script py my_script.py

If you still get an error when issuing python commands, use the official installer to configure Python correctly.

# Adding Python to your PATH using the official installer

If you still encounter issues, try to add Python to your PATH using the official installer.

  1. Download the installer from the official python.org website.

  2. If you have Python already installed, start the installer and click on "Modify".

click modify

You can leave the optional features ticked. Note that the pip checkbox is checked.

optional features

  1. On the "Advanced Options" screen, make sure to tick the "Add Python to environment variables" option.

add python to environment variables

  1. Once the "Add Python to environment variables" checkbox is checked, click "Install".
Now your Python installation should be set up correctly and Python should be added to your user's PATH environment variable.

If that didn't work, your Python installation might be corrupted.

# Reinstalling Python on your Windows machine

Start the installer again and click on "Uninstall".

uninstall python

Now that you don't have Python installed on your machine, start the installer again and make sure to tick the "Add python.exe to PATH" option.

add python exe to path

The checkbox won't be checked by default.

Once the "Add python.exe to PATH" checkbox is checked, click on "Install Now".

After the installation, Python will be installed and configured properly.

Close your Power Shell application and reopen it.

Note that you must restart Power Shell for the changes to take effect.

cmd
python --version python exit() python -m pip install requests

python command works

If you get a permissions error when issuing a python command, you have to open CMD as an administrator.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

Once you start CMD as an administrator, you should be able to issue python command without getting permission errors.

cmd
python --version python -m pip install requests python -m pip install requests --user

You can also use the --user option which installs the package for the specific user and doesn't require elevated permissions.

If the error persists, try to restart your PC to make sure you don't have stale IDE and shell sessions.

# Conclusion

To solve the error "Python was not found; run without arguments to install from the Microsoft Store", make sure:

  1. You have Python installed on your Windows machine.
  2. You have the path to Python in your user's PATH environment variable.
  3. You have disabled the Python App installer in "App execution aliases".

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev