2

So as the title says, I'm having problem starting a new subprocess under Fedora. Now the situation is, I have a main python script from which I start a couple of other python processes using:

import subprocess
subprocess.Popen(['python', '-m', 'first_child.run', 'start'], shell=False)

Now this works fine on MacOS, debian and windows. On fedora if I run it from Aptana 3 IDE it also works, the only problem is when i try to run this main scrip from a terminal, where I get:

OSError: [Errno 2] No such file or directory

Do you have any ideea what can be the problem here?

Regards, Bogdan

Bogdan
  • 8,017
  • 6
  • 48
  • 64
  • 1
    The first thing that comes to mind is SELinux, but I wouldn't know exactly what to check. – Rik Poggi Mar 29 '12 at 15:07
  • Anyway, why aren't you using the [`multiprocessing`](http://docs.python.org/py3k/library/multiprocessing.html) module? – Rik Poggi Mar 29 '12 at 15:09
  • To check for SELinux interference, tail `/var/log/audit/audit.log` while running the script. – Charles Mar 29 '12 at 16:45
  • Well no ideea what's happening but I just deleted the first_child.egg from site_packages and did another install using python setup.py develop instead of python setup.py install and now it seems to work fine. – Bogdan Mar 30 '12 at 09:13
  • @Bogdan: Than I'd say that there probably was an outdated info in the child or parent egg. – Rik Poggi Mar 31 '12 at 08:42

2 Answers2

1

Sorry if this is something you've already thought of -- but the most common cause of OSError from calls to subprocess is that it cannot find the process

http://docs.python.org/library/subprocess.html#exceptions

Are you absolutely certain python is in your path?

I know you're probably going to point out you ran this script from the python executable -- but I thought I'd take a shot that perhaps you specified the full path to python when you ran it from the terminal.

For fun, right before the call to subprocess, you could dump your PATH

import os
print os.environ['PATH']
user590028
  • 11,364
  • 3
  • 40
  • 57
1

It's your current working directory. I don't think the problem is that it can't find python, the problem is that it can't find first_child.run.

Try printing os.getcwd() before you launch the subprocess, and see if it's different in the terminal vs. in the IDE.

On a side note, it's probably more reliable to use sys.executable as the python you use in your subprocess, as opposed to just saying python. For example, subprocess.Popen([sys.executable, '-m', 'first_child.run', 'start'], shell=False)

forivall
  • 9,504
  • 2
  • 33
  • 58