I've just done a fresh install of Python 2.7.14 on Windows Server 2012. Whenever I try to execute any script, I get an Access Denied error. This is regardless of the script I try to run, even something simple like python -c "print 1" fails with the following error message in Powershell:

Program 'python.exe' failed to run: Access is deniedAt line:1 char:1
+ python -c "print 1"
+ ~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ python -c "print 1"
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

Whereas the same command in CMD just yields Access Denied.

This happens even when running as administrator with elevated UAC status, so I'm at a loss here. Any ideas as to what's going on?

Edit: Forgot to mention, for some reason interactive mode works just fine.

  • Sounds like a file association problem, like it's associating Python with a Powershell script. – Davidw Feb 7 '18 at 0:12

For what its worth...

I'd wager the case might very well be server antivirus. I've seen a very very similar situation with Comodo AV for Sever that was blocking script execution with its containment settings. (It was funny as it didn't do this for php, just python). We solved this by creating a new containment rule and telling it to ignore all (a file group) *.py files in a particular directory.

This worked immediately. Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.