I have an Errno 13 Permission denied with subprocess in python
Asked Answered
B

4

6

The line with the issue is

ret=subprocess.call(shlex.split(cmd))

cmd = /usr/share/java -cp pig-hadoop-conf-Simpsons:lib/pig-0.8.1-cdh3u1-core.jar:lib/hadoop-core-0.20.2-cdh3u1.jar org.apache.pig.Main -param func=cat -param from =foo.txt -x mapreduce fsFunc.pig 

The error is.

File "./run_pig.py", line 157, in process
    ret=subprocess.call(shlex.split(cmd))
File "/usr/lib/python2.7/subprocess.py", line 493, in call
  return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
  errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
  raise child_exception
OSError: [Errno 13] Permission denied

Let me know if any more info is needed. Any help is appreciated. Thanks.

Bounty answered 2/10, 2012 at 13:36 Comment(2)
In addition to @Woobe's comments, foo.txt won't be where you expect it to be when you run that command; you should pass foo.txt and fsFunc.pig with their full path names.Diversify
This program currently runs when executed from the server it is on. I am trying to get this to run on my Ubuntu desktop. foo.txt not existing is not a current issue, it is simply a placeholder for now.Bounty
C
10

The error indicates that /usr/share/java does not have permissions that will allow you to execute it, probably because it is a directory, not an executable.

Find the location of the java executable on your Ubuntu machine (probably /usr/bin/java) and change /usr/share/ to point to the right place.

Calcify answered 2/10, 2012 at 15:35 Comment(2)
Java was not properly installed in bin/java, this fixed it.Bounty
In general, the error seems to mean something isn't executable for the current user. You can probably fix the error by using chmod +x executable.Smarm
W
1

just type chmod -R 777 /your/project/

its works for my...

Warhorse answered 29/3, 2016 at 13:25 Comment(1)
chmod -R 777 /your/project/ makes everything in the project readable, editable, and executable by any users on the system. You are better off doing: chmod -R +x /your/project/. This just makes everything executable by any user on the system, or just finding the executable and doing chmod +x executable is better again. This improves security.Smarm
L
0

That's an OS permissions error. It means your user doesn't have permission to write to that directory/file. It's nothing to do with Python.

Larvicide answered 2/10, 2012 at 15:20 Comment(0)
G
0

you could also try setting shell=True as the second argument in you subprocess.call(), that may work.

ret = subprocess.call(shlex.split(cmd), shell=True)

cmd = /usr/share/java -cp pig-hadoop-conf-Simpsons:lib/pig-0.8.1-cdh3u1-core.jar:lib/hadoop-core-0.20.2-cdh3u1.jar org.apache.pig.Main -param func=cat -param from =foo.txt -x mapreduce fsFunc.pig 
Gentlemanfarmer answered 6/8, 2019 at 17:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.