0

I have a problem with running files through python. This is my code :

def report1(self):
   str="/Users/Apple/Desktop/Report1.exe"
   subprocess.call(str)


This is the error i am getting : 
File "./DBMS.py", line 427, in <module>
Main().run();
File "./DBMS.py", line 415, in run
self.report1()
File "./DBMS.py", line 383, in report1
subprocess.call(str)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",      line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception

OSError: [Errno 13] Permission denied

PS: i tried changing permission rights on folders and i tried using subprocress.Popen . i also tried adding shell=True. i don't understand why its still not working .

any help is really appreciated. have to submit in 24 hours :(

6
  • This is on Windows? Can you open a command prompt and run the exe outside of python? Commented Aug 24, 2014 at 22:10
  • this is on mac . working fine on windows :( Commented Aug 24, 2014 at 22:12
  • How are you expecting to run an exe file on a Mac? Commented Aug 24, 2014 at 22:14
  • I'm not an expert on macs, but generally you'd need an emulator like wine to run a windows exe on mac, and even then, only some programs will work that way. Commented Aug 24, 2014 at 22:17
  • i actually have wine on the mac but its not running it . daniel is right i think i have to make my executable not .exe Commented Aug 24, 2014 at 22:21

2 Answers 2

1

For all its merits, subprocess doesn't make it abundantly clear when an error has occurred while trying to execute a command.

If the deepest frame in your traceback (the one right before the actual exception) is raise child_exception from subprocess.py, that means there was some issue inclusively between the fork(2) and exec*(2) calls -- in other words, that an error occurred while trying to run the command you requested.

The actual exception you pasted was OSError: [Errno 13] Permission denied. An errno of 13 corresponds to EACCES:

>>> import errno; print errno.errorcode[13]
EACCES

If you've never used fork(2) or exec(2) things will be pretty inscrutable, because subprocess has dropped the real traceback. However, I can tell you that this OSError almost certainly came from the exec* call. It turns out execve raises this under the following conditions:

 [EACCES]           Search permission is denied for a component of the
                    path prefix.

 [EACCES]           The new process file is not an ordinary file.

 [EACCES]           The new process file mode denies execute permission.

 [EACCES]           The new process file is on a filesystem mounted with
                    execution disabled (MNT_NOEXEC in <sys/mount.h>).

(Courtesy of Apple)

If I had to guess, you encountered this this exception because the command you're trying to run isn't marked executable (with something like chmod u+x).

Now, it's unlikely that your .exe file will run on your Mac after solving this, but at least it'll be a different error!

Sign up to request clarification or add additional context in comments.

Comments

0

Try running your program as sudo:

sudo python mycode.py

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.