Plotly: Command 'orca' not found @win/processx.c:983

Created on 8 Apr 2020  路  14Comments  路  Source: ropensci/plotly

I want to export a plotly object to a static image using plotly::orca on Win10, but I'm a getting the following error:

<c_error in rethrow_call(c_processx_exec, command, c(command, args), stdin,  ...:
 Command 'orca' not found @win/processx.c:983 (processx_exec)>

The problem seems to be not orca itself but processx::run. I wrote my own little orca function using base::system instead which works just fine.

Here is the same issue.


    p <- plot_ly(mtcars, x = ~mpg, y = ~wt)

    ## Fails
    plotly::orca(p)

    ## Works
    file = "plot.png"; format = "png"
    debug=verbose=safe=F
    b <- plotly_build(p)
    plotlyjs <- plotly:::plotlyjsBundle(b)
    plotlyjs_path <- file.path(plotlyjs$src$file, plotlyjs$script)
    if (!is.null(plotlyjs$package)) {
      plotlyjs_path <- system.file(plotlyjs_path, package = plotlyjs$package)
    }
    tmp <- tempfile(fileext = ".json")
    cat(plotly:::to_JSON(b$x[c("data", "layout")]), file = tmp)
    args <- c("graph", tmp, "-o", file, "--format", 
              format, "--plotlyjs", plotlyjs_path, if (debug) "--debug", 
              if (verbose) "--verbose", if (safe) "--safe-mode")
    base::system(paste("orca", paste(args, collapse = " ")))

Most helpful comment

Hello @cpsievert,

I'm now maintaining Orca and I've had several reports of problems running Orca in R since its 1.3.1 release. It seems like @trafficonese found the culprit although I can't say for sure since I'm not familiar with R.

Anyway, if there is a problem with Orca itself (or how it's packaged), please let me know and I will gladly fix it.

Thank you for your time :smile_cat:

All 14 comments

Thanks @trafficonese for opening this issue!

cc @rpkyle

Hello @cpsievert,

I'm now maintaining Orca and I've had several reports of problems running Orca in R since its 1.3.1 release. It seems like @trafficonese found the culprit although I can't say for sure since I'm not familiar with R.

Anyway, if there is a problem with Orca itself (or how it's packaged), please let me know and I will gladly fix it.

Thank you for your time :smile_cat:

Looks as though there has been some recent Windows-related activity in r-lib/processx, would you mind installing the dev version and seeing if that fixes the issue?

remotes::install_github("r-lib/processx")

@cpsievert the development version of processx seems not to work too. But I can use orca through the command line.

I have figured out the problem on windows. The PATH added should be system-wide rather than user. Adding the variable path system-wide resolved the problem of orca not being found.

@asimumba which path are you talking about? The path to the orca.cmd file that's run? I found that path with where orca and then added it to the System 'Path' env variable, but still no luck.

@antoinerg What's the reasoning for using processx vs base::system to run orca? For me, I'm having huge issues figuring out how to get processx working on Windows. It doesn't seem to recognize any environment variables and can't run any commands. system() works fine though.

Ok, here is the solution: install orca with the windows release and add the path to the System Path env variable.

Originally, I had installed orca with conda: conda install -c plotly plotly-orca. This installed orca.cmd to C:\Users\myusername\Anaconda3orca.cmd. I had to install orca from the windows release (https://github.com/plotly/orca/releases/tag/v1.3.1), which it installed to C:\Users\myusername\AppData\Local\Programsorca.exe. Then I added this path to my System Path env variable, logged out and back in, and it worked.

For some reason, in Windows, processx doesn't seem to work with .cmd files without using the extension, but can run .exe files with or without the extension. See my issue on it here if interested: https://github.com/r-lib/processx/issues/273

@gaborcsardi said that it's not possible to implement .cmd recognition by processx (See https://github.com/r-lib/processx/issues/273#issuecomment-697578198), so the only solution seems to use a system call instead of processx as proposed by @trafficonese. I tried it with a NPM installation of orca and it works just fine.

Well, what I said is that you need to start a shell. :) Like system does. Or, if you know that orca is orca.cmd on Windows, then call orca.cmd instead of orca.

It works great (ie @trafficonese solution). Any suggestions on how to allow for LaTeX symbols (e.g. for axis titles)?

See: https://plotly.com/r/LaTeX/

Thanks! Yes, I know how to apply TeX on plot_ly. I was perhaps not explicit enough; I am not sure how to use the solution of saving figures with TeX symbols as it does not work directly. Minimal example (plot.png has $\rho$ on y axis):

'# figure with LaTeX:
y <- list(title=TeX("\rho"))

p <- plot_ly(z = volcano, type = "heatmap")
p <- p %>% layout(yaxis = y)
p <- p %>% config(mathjax = 'cdn')
p

'# trafficonese solution:
file = "plot.png"; format = "png"
debug=verbose=safe=F
b <- plotly_build(p)
plotlyjs <- plotly:::plotlyjsBundle(b)
plotlyjs_path <- file.path(plotlyjs$src$file, plotlyjs$script)
if (!is.null(plotlyjs$package)) {
plotlyjs_path <- system.file(plotlyjs_path, package = plotlyjs$package)
}
tmp <- tempfile(fileext = ".json")
cat(plotly:::to_JSON(b$x[c("data", "layout")]), file = tmp)
args <- c("graph", tmp, "-o", file, "--format",
format, "--plotlyjs", plotlyjs_path, if (debug) "--debug",
if (verbose) "--verbose", if (safe) "--safe-mode")
base::system(paste("orca", paste(args, collapse = " ")))

Ok, here is the solution: install orca with the windows release and add the path to the System Path env variable.

Originally, I had installed orca with conda: conda install -c plotly plotly-orca. This installed orca.cmd to C:\Users\myusername\Anaconda3orca.cmd. I had to install orca from the windows release (https://github.com/plotly/orca/releases/tag/v1.3.1), which it installed to C:\Users\myusername\AppData\Local\Programsorca.exe. Then I added this path to my System Path env variable, logged out and back in, and it worked.

This worked for me as well.

Was this page helpful?
0 / 5 - 0 ratings