Last updated: Apr 10, 2024
Reading timeยท6 min
The error "Python was not found; run without arguments to install from the Microsoft Store" occurs for 2 main reasons:
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.
# ๐๏ธ 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
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
.
py -0
command to check which Python versions are installed on your machine.py -0
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
.
# ๐๏ธ 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
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.
Then select the correct Python version from the dropdown menu.
If the error is not resolved, you have to add the path to Python and pip
to
your PATH environment variable.
To add the path to Python to your user's PATH environment variable:
py -c "import os, sys; print(os.path.dirname(sys.executable))" python -c "import os, sys; print(os.path.dirname(sys.executable))" where python
For me, the path is the following.
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310
Note that I have Python 3.10 installed, which is reflected in the PATH.
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.
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\Scripts
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.
# ๐๏ธ 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
If you still get the error, you have to disable the Python App installer in "App execution aliases".
python --version
command.If the error persists, try using py
instead of python
.
# ๐๏ธ 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.
If you still encounter issues, try to add Python to your PATH using the official installer.
Download the installer from the official python.org website.
If you have Python already installed, start the installer and click on "Modify".
You can leave the optional features ticked. Note that the pip
checkbox is
checked.
If that didn't work, your Python installation might be corrupted.
Start the installer again and click on "Uninstall".
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.
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.
python --version python exit() python -m pip install requests
python
command, you have to open CMD as an administrator.To open CMD as an administrator:
Click on the Search bar and type CMD.
Right-click on the Command Prompt application and click "Run as administrator".
Once you start CMD as an administrator, you should be able to issue python
command without getting permission errors.
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.
To solve the error "Python was not found; run without arguments to install from the Microsoft Store", make sure:
You can learn more about the related topics by checking out the following tutorials: