This error indicates that the Python installation on your machine has been installed from the Microsoft Store. MATLAB does not support CPython versions installed from the Microsoft store. For supported version information, please check the following link:
Please use the following link to install the correct Python version supported by your version of MATLAB.
Subsequently, after installing Python, you may get a "ModuleNotFoundError" as shown below:
Error using __init__><module>
Python Error: ModuleNotFoundError: No module named 'packaging'
In this case, please consider the following:
- The first step is to ensure that the default version of Python to which modules are installed to on Windows Command Prompt is the version that MATLAB is using. This can be verified by running Python on Windows Command Prompt and typing the following commands.
> import sys
> print(sys.exec_prefix)
- If the default version of Python is not one that is supported by MATLAB, it is necessary to add the supported Python installation path to the Environment variables. This can be done as follows:
- Right click on “This PC” from your file explorer and click on Properties.
- Click on the Advanced System Settings on this page and click on “Environment Variables”.
- In the list of “User Variables”, edit the “Path” variable.
- Ensure that your Python installation path is higher up on this list than the “WindowsApps” path. The "WindowsApps" path points to the directory in which the Microsoft store installation of Python resides.
- Another way to install packages for a specific version of Python is by running the following command:
> <path-to-python.exe> -m pip install <module>