The Python Oracle

Python script works fine on Linux, on Windows, causes WindowsError: [Error 5] Access is denied

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Industries in Orbit Looping

--

Chapters
00:00 Python Script Works Fine On Linux, On Windows, Causes Windowserror: [Error 5] Access Is Denied
00:43 Answer 1 Score 1
01:03 Accepted Answer Score 5
01:48 Thank you

--

Full question
https://stackoverflow.com/questions/1183...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #windows #windowsxp

#avk47



ACCEPTED ANSWER

Score 5


According to the documentation, the first item in the argument sequence (in this case, the first element of command) is interpreted as the program to execute.

Looking at the first element of command, it would appear that you're trying to execute a directory. Windows (somewhat non-intuitively) returns an access denied error whenever you try to read from a directory as if it were a file, and the same thing happens if you try to execute one.

Instead of c:\python27 you probably want c:\python27\bin\python.exe or something similar. At any rate, you need to be pointing at the executable, not at the directory. I'm not sure why this works for you on Linux.




ANSWER 2

Score 1


Your program doesn't have access to the file... check permissions on the file you're trying to access, then go from there... (ie, either elevate the Python interpreter's permissions, or reduce access required to said resource) - either way - tread carefully.