5

When trying to run Python 3.7 on Windows 10 with Git Bash I get the following error:

$ python --version
bash: /c/Users/Name/AppData/Local/Microsoft/WindowsApps/python: Permission denied

What to do?

Edit: I solved (or rather circumvented) this by installing python using scoop and using cmder instead of Git Bash.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
General Gravicius
  • 181
  • 1
  • 2
  • 10
  • 4
    Why is this question closed? *"We don’t allow questions about general computing hardware and software on Stack Overflow"* this question is about a very specific issue on using Python on Windows, it's 100% relevant to StackOverflow. – Markus Meskanen Mar 16 '20 at 11:11
  • 1
    Yep. It helped me. – Mote Zart Jul 27 '20 at 16:24

2 Answers2

9

Python isn't actually installed. That's a shim which should open the Windows store, but it only works from PowerShell or CMD (and only does that correctly some of the time). I recommend visiting the Python website and downloading and installing from there.

Here is the blog post announcing this "feature": https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/

This SuperUser article discussed solutions: https://superuser.com/questions/1437590/typing-python-on-windows-10-version-1903-command-prompt-opens-microsoft-stor

Sumner Evans
  • 8,951
  • 5
  • 30
  • 47
  • 1
    I've already installed though, and from the Python website. I can use it with PyCharm. – General Gravicius Dec 03 '19 at 01:14
  • Make sure you add it to your `$PATH` from within Git Bash. – Sumner Evans Dec 03 '19 at 01:16
  • I did that as well. `$ export path="$PATH:/c:/Users/Name/AppData/Local/Programs/Python/Python37" ` – General Gravicius Dec 03 '19 at 01:28
  • When installed "%LocalAppData%\Microsoft\WindowsApps\python.exe" is a special kind of appexec reparse point that's used by `CreateProcessW` to set up the security context that allows executing the real executable that's in a subdirectory of "%ProgramFiles%\WindowsApps". By design, this reparse point is not handled by the I/O manager or any filter drivers in the kernel, so code that naively tries to open that path with reparsing enabled (by default) will fail. bash, or more specifically Cygwin/MSYS2, does exactly this and thus needs to be patched in order to support appexec links. – Eryk Sun Dec 03 '19 at 02:41
  • You need to do `export PATH="/c/Users/Name/.../Python/Python37:$PATH`. Notice that the `$PATH` is after the new addition. That's because Linux will look in order at each of the directories in the `$PATH` and if the desired executable exists in the directory, it will use that one. Also, note that you do not want a `:` after `c` in the Linux `$PATH` since `:` is the separator character for path elements. – Sumner Evans Dec 03 '19 at 04:42
  • 1
    You mean bash, not Linux. git-bash is based on MSYS2, which is derived from Cygwin. – Eryk Sun Dec 03 '19 at 12:47
0

I also received "Permission Denied" message from Git Bash. What worked for me was using "py":

py file_name.py

Reference: Difference between Py and Python

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77