plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.57k stars 627 forks source link

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

Open trafficonese opened 4 years ago

trafficonese commented 4 years ago

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 = " ")))
antoinerg commented 4 years ago

Thanks @trafficonese for opening this issue!

cc @rpkyle

antoinerg commented 4 years ago

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:

cpsievert commented 4 years ago

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")
asimumba commented 4 years ago

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

asimumba commented 4 years ago

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.

nateGeorge commented 4 years ago

@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.

nateGeorge commented 4 years ago

@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.

nateGeorge commented 4 years ago

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\Anaconda3\orca.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\Programs\orca.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

DDorch commented 4 years ago

@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.

gaborcsardi commented 4 years ago

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.

jstriaukas commented 4 years ago

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

ismirsehregal commented 4 years ago

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

jstriaukas commented 4 years ago

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 = " ")))

SansMorel commented 3 years ago

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\Anaconda3\orca.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\Programs\orca.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.

jennykathambi90 commented 3 years ago

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\Anaconda3\orca.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\Programs\orca.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: r-lib/processx#273

This has worked for me thank you so much.

c06n commented 3 years ago

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\Programs\orca.exe. Then I added this path to my System Path env variable, logged out and back in, and it worked.

Small correction: I think the path added to system PATH should be C:\Users\myusername\AppData\Local\Programs\orca. orca.exe did not work for me.