1

I am building on package using python script on yocto Pyro.

In Python script i am using subprocess.Popen.

As per my understanding when the Python Script runs for Cross Platform then it should take Cross-platfrom Python subprocess path however in my case its take native path "/usr/lib/python2.7/subprocess.py" i.e of PC.

Because of that i am facing in _execute_child raise child_exception. Can any help to resolve this issue ?

Error is below

 File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
     process = Popen(stdout=PIPE, *popenargs, **kwargs)
 File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
     errread, errwrite)
 File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
  raise child_exception
 OSError: [Errno 2] No such file or directory

PS: i have already tried "shell=True" option but it did not resolve my issue.

Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
Viraj m
  • 11
  • 1

2 Answers2

2

If you're running a script at build time then it will run the host python as it can't run the target python binary for the obvious reason that its a target binary.

The exception your showing is simply that you're trying to run a binary that popen can't find. Remember that inside a build $PATH is sanitised so won't contain what it has outside of bitbake.

Ross Burton
  • 3,516
  • 13
  • 12
0

You should set an environment variable which points to the desired python setup and pass it to the subprocess call. Something like this

export venv='/path/to/python'

venv = os.environ["VENV_PYTHON"]
p = subprocess.Popen([venv, command], env=os.environ.copy())

This will launch your python script with the desired python setup

Priyank Mehta
  • 2,453
  • 2
  • 21
  • 32