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.

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.

After the installation has finished, I went to the Windows Terminal, typed in python
and hit enter or 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).
Then I checked my user path variables and I found nothing but a single entry sitting there for an unknown amount of time.

No Python! But since it is the path for all applications installed from the Microsoft Store, I took the initiative to go to C:
using File Explorer.

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
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
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)
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)
Then I just realized that somehow all the files under C:
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
Wait, how come! It had been confusing me. The package went into somewhere which in my case went into %USERPROFILE%
. 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'
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.

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)"
You can read from the official website on this specific issue. I hope you get the idea. Thanks for reading!