PlotlyJS causes errors, can't figure out how to use PlotlyLight - how to use Plotly from Julia?

The @tmp environment does not seem to be the actual problem…
I have noticed that after a full Windows restart, PlotlyJS works well and I can save SVG figures the first time I run Julia (with Plotly in the @tmp environment).
But after restarting Julia, I get the behaviour I was getting before (hang on using PlotlyJS). So I think what happened the first time I tried with the shared environment is simply I hadn’t restarted Windows. And it is also likely that when I got it working in the main environment, it was only working “once”, it would have failed if I had tried restarting Julia (I am not sure of course but I have had enough reinstalling everything to try).

I have noticed Julia launches several kaleido.exe instances when using PlotlyJS, but they don’t seem to be running anymore after I close Julia, so I haven’t been able to identify what is different the first time I run Julia from other times… I can even move the whole artifact\7914… directory (the one with kaleido), so clearly nothing is locking it. But there must be something hanging around.

I am getting discouraged with PlotlyJS because the more I search, the more I find about similar problems, but no solution, only workarounds that seem to work for some users but not for others. And my own experience confirms that sometimes you think it’s working and then you realize it’s only working once!

I read about PlutoPlotly, I do not intend to use Pluto, but is there any way this could be a better alternative to use Plotly and be able to save SVG from Julia?

I do not think your problem is related to PlotlyJS.jl. I have been teaching a course using this package extensively with more than 300 students a year (3 years, more than a thousand users), and I have never encountered a similar problem to yours. Although most students use Pluto notebooks, some also go with VScode. No problem at all with rendering the plots and saving them as png, pdf, svg, and other formats.

In one of my previous entries in this thread, I wrote something that is not (apparently) correct. Last October, @disberd mentioned the following here :

" The package also got a new breaking release recently and now should have feature parity with PlotlyJS so that every function you can use in PlotlyJS also works in PlutoPlotly.

I am also working on a new release to have it work also outside of Pluto (both standalone html and vscode/documenter) so that it can be potentially used as an alternative to PlotlyBase/PlotlyJS with the same syntax, since those two packages have been having some issues with updates"

I have tested PlutoPlotly in VScode, and it does not render the plots despite no error spitting out. Maybe I am doing something wrong, or perhaps @disberd encountered unexpected problems preventing PlutoPlotly from being used outside Pluto.

Plotly and PlotlyJS are mature packages. Your problem looks very specific to your machine. For example, I have access to two similar computers: at home, I can plot with Plots.jl without problems; at work, Plots.jl does not precompile. I believe the problem is associated with permissions.

Thank you for your comment, I find it reassuring there is hope, but I really have no clue how my machine could be “non-standard” (assuming you are also on Windows, as it does seem a Windows issue). I am a local administrator on my machine, it is not on a domain, I have a regular, simple 3-letter user name without special characters, I would assume my configuration is very similar to many others (windows 10, not 11).
I have also changed the permissions on the whole .julia folder as advised by oheil.

I am a bit skeptical on “very specific to your machine” because these problems seem to have been there for a long time and there is still (at least) one open issue on them (or at least similar problems):

(but this being said, I am of course willing to admit that the problems happen on some specific machines and not on all machines!)

Also, if it’s a permission issue, I don’t see why I am able to use PlotlyJS once, but then, if I restart Julia, it fails, until I also restart Windows.

You said you are teaching a course, do you give specific instructions on how to install Julia and the packages? Perhaps there is some mysterious order or way to install things?

I like to do it manually. Undergrad students follow this set of instructions. Master students follow the same instructions but install more packages and VScode.

As mentioned, there is something strange in the computer I use in my office (Windows 10). It is the only computer that I have seen that suffers from that “Plots fails to precompile” thing. I installed Plots in around 10 different computers to see what was happening (Windows and Linux), and it works in all of them with that exception. The IT people have been there to try to figure out what was wrong with the configuration of the machine, and I followed many threads that focus on this issue. No success. Plots is still not precompiling.

Something to check for you @jojob68
The Julia REPL, when using PlotlyJS, fires up 4 kaleido processes on my Windows 10.
You can see them in the Task Manager.
Opening another REPL and using PlotlyJS again fires 4 more.

Closing a REPL immediatly closes all 4 kaleido processes belonging to this REPL.

If you check if this is all right on your machine too, than I don’t know. If not, which I expect, we can dig deeper. My guess is, that you somehow get some hanging kaleido processes which block your further experiences.

Let’s don’t give up, we will beat Windows at the end.

I am puzzled what is going on with the “kaleido” command. I tried this in the CMD window on Windows 11:

The folder name either without quotes or with " works fine. But as constructed in PlotlyJS kaleido.jl file with apostrophes ('), it fails! It works in the Terminal with the PowerShell, but NOT in CMD. Just changing the directory is a problem:


Is this something new in Win 11? I thought it was supposed to work!?

Could this explains the difficulties with Kaleido?

The backticks are the reason the path is constructed this way:
image

I think this is just a display thing:

julia> dump(BIN)
Cmd
  exec: Array{String}((4,))
    1: String "C:\\Users\\Oli\\.julia\\artifacts\\7914a56da888d6a06d00c87f97e873c60e97acc7\\kaleido.cmd"
    2: String "plotly"
    3: String "--disable-gpu"
    4: String "--no-sandbox"
  ignorestatus: Bool false
  flags: UInt32 0x00000000
  env: Nothing nothing
  dir: String ""
  cpus: Nothing nothing

I have experienced intermittent Kaleido failure on Windows (it gave error in some machines and in some occasions) and one thing I had success with (in CI windows tests and a on a problematic windows 10 machine) was to explicitly force the Kaleido_jll library to version 0.1 (like I did in this commit).

You can simply force the lower version on the underlying Kaleido library by adding it explicitly in your environment where you also load PlotlyJS. Like so (in a temp environment):

(jl_AvCp4j) pkg> add PlotlyJS, Kaleido_jll@v0.1

Try it out and see if this might solve your issue with loading Kaleido.

2 Likes

seem to help others too: https://github.com/plotly/Kaleido/issues/110

Yeah that was the issue that made me try that

1 Like

Hmm, what is causing the trouble with the kaleido command then? I tried changing the permissions, no luck.

The 4 instances are closed properly (and I can even move the artifacts forlder, so nothing seems to be left running).

Thanks for the link to instructions. Impressive website!
Regarding your office computer, perhaps a windows home vs windows pro (or enterprise) difference would be the cause? My windows version is professional.

Thank you for the suggestion.
I have installed the 2 packages (and only that) as suggested, and it seems to fix the problem (after changing again the permissions on the artifacs folder). I say seem because unfortuately this issue seems to be a sneaky one, so I will do more testing (for example with other package also installed, after multiple restarts, etc.).
But definitely I am having more consistent successes creating svg images after this suggestion.
[Edit: the suggestion by disberd that I am replying to is to add PlotlyJS, Kaleido_jll@v0.1 in a new environment.]

2 Likes

So far so good…
I have reinstalled everything as when I started this thread, and PlotlyJS seems to be able to save SVG files consistently.
Thanks a lot to everyone who provided input.
To sum up what was needed:

  1. add the Kaleido_jll package and force it to version 0.1 after adding PlotlyJS (instruction: add Kaleido_jll@v0.1 in package mode) - for people like me who read too fast, do not add Kaleido but Kaleido_jll, it’s not the same thing!)
  2. Change the permissions inside the .julia folder. I suspect changing the permissions of the directory with “kaleido.cmd” is enough, but I just changed the permissoins on the whole .julia directeory with: (in CMD prompt, not in Julia): icacls C:\Users\%UserName%\.julia /grant %UserName%:(OI)(CI)RX /C /T.
    Note that you need to do that after adding the packages, it seems installing them changes the permissions again.

As I said, I am really grateful to everyone who helped.
I am a bit disappointed at the new world I am discovering coming from Matlab. The problems seem to have been present for a very long time (and they don’t seem to be Julia-specific, at least for some of them) , and yet the PlotlyJS documentation is silent on the “permissions” problem and on the Kaleido problems.

2 Likes

I tried that on the repo, but it didn’t help in CI

That’s unfortunate :/.
Kaleido (the C library) also seems to be going towards abandonware as no new feature or bug fix has been done for a while…

The specific issue with PlotlyJS and windows should now be fixed after version 2.2.4 of PlotlyKaleido was released

In machines where the problem was happening it is still required to downgrade Kaleido_jll to version 0.1 but this is now mentioned as a warning when loading the package. See this github comment for more details.

2 Likes