Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orca CLI doesn't work with Python subprocess.Popen #95

Open
PlotlyUser2 opened this issue Jun 3, 2018 · 7 comments
Open

Orca CLI doesn't work with Python subprocess.Popen #95

PlotlyUser2 opened this issue Jun 3, 2018 · 7 comments

Comments

@PlotlyUser2
Copy link

PlotlyUser2 commented Jun 3, 2018

Well, I've just tried to create an image by using orca within the python api. However this code doesn't produce any image:

import subprocess

json_res = json.dumps({"data": [{"y": [1,2,1]}]})
command = f"orca graph {json_res} -o fig.png" 
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=None, shell=True)

#Launch the shell command:
output = process.communicate()

print (output[0])

It returns: done with code 1 in 2.59 ms - failed or incomplete task(s)

@etpinard
Copy link
Contributor

etpinard commented Jun 4, 2018

Thanks for the report. Nothing appears suspicious.

I ran

from subprocess import call
import json

fig = {"data": [{"y": [1,2,1]}]}
call(['orca', 'graph', json.dumps(fig)])

as in the README instructions again in Python3.5 and things work fine.

Maybe someone more familiar with python's subprocesses could help us out?

@PlotlyUser2
Copy link
Author

@etpinard When I try to run your code piece, I get the FileNotFoundError: [WinError 2] error. But when I run this:

from subprocess import call
import json

fig = {"data": [{"y": [1,2,1]}]}
call(['orca', 'graph', json.dumps(fig)], shell=True)

Out[2]: 0

Well, then I get 0.

@etpinard
Copy link
Contributor

etpinard commented Jun 4, 2018

Well, then I get 0.

If that 0 means exit code 0, then the export should have succeeded.

@PlotlyUser2
Copy link
Author

Where does the image file should be created?

@etpinard
Copy link
Contributor

etpinard commented Jun 4, 2018

in the same directory as where you're running your script.

@PlotlyUser2
Copy link
Author

PlotlyUser2 commented Jun 4, 2018

Yup, your code works. Thanks!

But still the above code fails.

@kengz
Copy link

kengz commented Jun 16, 2018

I can confirm the above too. Not using the shell argument works, and file will save to the expected output.

@etpinard etpinard changed the title Orca Python API doesn't produce any image Orca CLI doesn't work with Python subprocess.Popen Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants