DEV Community

loading...

Why I Didn't Install Python from the Microsoft Store

naruaika profile image Naufan Rusyda Faikar Updated on ・5 min read

I am a big Python fan! So, please do not stop me from installing Python on Windows. As far as I know, we have two ways of doing it. The first option is we can download the installer from the official page which I believe this is the solution preferred by the most users.

Alt Text

But come on, I do not want to bother Microsoft Defender SmartScreen! So, I went to the second option which is to download it from Microsoft Store! Love it! This is the easiest way to take it home! Please note that there are actually a few other options, but I am just too lazy to say it all.

Alt Text

After the installation has finished, I went to the Windows Terminal, typed in python and hit enter/return key within a second or two. Suddenly, I got a horror error message screaming at me in red.

> python
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

> where.exe python
INFO: Could not find files for the given pattern(s).
Enter fullscreen mode Exit fullscreen mode

Then I checked my user path variables and I found nothing but a single entry sitting there for an unknown amount of time.

Alt Text

No Python! But since it is the path for all applications installed from the Microsoft Store, I took the initiative to go to C:\Users\Naufan Rusyda Faikar\AppData\Local\Microsoft\WindowsApps using File Explorer.

Alt Text

From there, I had found that it have to be python3.9 with the specific version as a suffix. Alright, I had no problem with that.

> where.exe python3.9
C:\Users\Naufan Rusyda Faikar\AppData\Local\Microsoft\WindowsApps\python3.9.exe

> where.exe pip
C:\Users\Naufan Rusyda Faikar\AppData\Local\Microsoft\WindowsApps\pip.exe
Enter fullscreen mode Exit fullscreen mode

Before installing some packages, I used to upgrade pip. Inspite of my success, a warning had plagued the day.

> python3.9 -m pip install --upgrade pip
Collecting pip
  Downloading pip-20.2.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 525 kB/s
Installing collected packages: pip
  WARNING: The scripts pip.exe, pip3.9.exe and pip3.exe are installed in 'C:\Users\Naufan Rusyda Faikar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.4
Enter fullscreen mode Exit fullscreen mode

Do you realize where the inconsistency lies? Let me make it clearer.

> where.exe pip
C:\Users\Naufan Rusyda Faikar\AppData\Local\Microsoft\WindowsApps\pip.exe

> pip --version
pip 20.2.4 from C:\Users\Naufan Rusyda Faikar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)
Enter fullscreen mode Exit fullscreen mode

The where.exe command had no knowledge of where the "usable" pip command is. Even if I did get more specific.

> where.exe python3.9
C:\Users\Naufan Rusyda Faikar\AppData\Local\Microsoft\WindowsApps\python3.9.exe

> python3.9 -m pip --version
pip 20.2.4 from C:\Users\Naufan Rusyda Faikar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)

> & 'C:\Users\Naufan Rusyda Faikar\AppData\Local\Microsoft\WindowsApps\pip.exe' --version
pip 20.2.4 from C:\Users\Naufan Rusyda Faikar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)
Enter fullscreen mode Exit fullscreen mode

Then I just realized that somehow all the files under C:\Users\Naufan Rusyda Faikar\AppData\Local\Microsoft\WindowsApps are "shortcuts" to the actual executable. I do not care anymore because I got the latest version of pip!

Next, I wanted to create a virtual environment for testing.

> pip install virtualenv
...

> virtualenv venv
virtualenv : The term 'virtualenv' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ virtualenv venv
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (virtualenv:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Enter fullscreen mode Exit fullscreen mode

Wait, how come! It had been confusing me. The package went into somewhere which in my case went into %USERPROFILE%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts. Okay, let's go another way.

> python3.9 -m virtualenv venv
RuntimeError: failed to build image pip because:
Traceback (most recent call last):
  File "C:\Users\Naufan Rusyda Faikar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\virtualenv\seed\embed\via_app_data\via_app_data.py", line 57, in _install
    installer.build_image()
  File "C:\Users\Naufan Rusyda Faikar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 54, in build_image
    zip_ref.extractall(str(self._image_dir))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\lib\zipfile.py", line 1633, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\lib\zipfile.py", line 1687, in _extract_member
    open(targetpath, "wb") as target:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Naufan Rusyda Faikar\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\Local\\pypa\\virtualenv\\wheel\\3.9\\image\\1\\CopyPipInstall\\pip-20.2.4-py2.py3-none-any\\pip\\_vendor\\urllib3\\packages\\ssl_match_hostname\\_implementation.py'
Enter fullscreen mode Exit fullscreen mode

Huh!? Microsoft is making things complicated! I have read from a GitHub issue page that I had most likely just reached the Windows long path limit. But I had to stop here, so that this post will not be too long in resentment.

Please note, if you want to install Python on Windows, I would recommend to go with the first option. As you can see in the attachment below, the installer gives you the option to disable the path length limit.

Alt Text

Actually, it will run a similar command in PowerShell as below.

> & 'C:\Users\Naufan Rusyda Faikar\AppData\Local\Programs\Python\Python39\pythonw.exe' -c "import winreg; winreg.SetValueEx(winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, r'SYSTEM\CurrentControlSet\Control\FileSystem'), 'LongPathsEnabled', None, winreg.REG_DWORD, 1)"
Enter fullscreen mode Exit fullscreen mode

You can read from the official website on this specific issue. I hope you get the idea. Thanks for reading!

Discussion (3)

pic
Editor guide
Collapse
thefern profile image
Fernando B 🚀

I've never install anything from windows store lol. Python I go straight to the python website everytime or use chocolatey.

Collapse
0916dhkim profile image
Donghyeon Kim

To be fair, it is not just Python. Windows' package management is half broken for pretty much everything. I think developers are better off with Linux or Mac.

Collapse
saint4eva profile image
saint4eva

Better use winget.