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

**URL:** <https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853>\
**Category:** New to Julia\
**Tags:** plotlyjs\
**Created:** [January 16, 2024, 4:57am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853 "2024-01-16T04:57:59Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![jojob68](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jojob68](https://discourse.julialang.org/u/jojob68)\
**Post date:** [January 19, 2024, 12:28am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/22 "2024-01-19T00:28:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [January 19, 2024, 1:57am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/23 "2024-01-19T01:57:05Z")

</div>

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](https://discourse.julialang.org/t/cannot-use-plotlyjs/105057/7) :

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

---

<div class="post-metadata">

**Author:** ![jojob68](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jojob68](https://discourse.julialang.org/u/jojob68)\
**Post date:** [January 19, 2024, 3:51am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/24 "2024-01-19T03:51:40Z")

</div>

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):

> [@Kaleido error: with Julia 1.6, the artifact seems to be broken](https://discourse.julialang.org/t/kaleido-error-with-julia-1-6-the-artifact-seems-to-be-broken/54475):
>
> [https://github.com/sglyon/PlotlyBase.jl/issues/40](https://github.com/sglyon/PlotlyBase.jl/issues/40) Would anyone have some insight into this problem? It appears to be happening on Linux and Windows. Can you confirm?

> <https://github.com/JuliaPlots/PlotlyJS.jl/issues/479>
>
> Julia 1.10 on windows 11.
> …                                                                                                      
> ┌ Warning: Kaleido is not available on this system. Julia will be unable to save images of any plots.                                                                                                            
> └ @ PlotlyJS C:\\Users\\pkonl\\SublimeJulia\_1\_10\_0\\assets\\.julia-1.10.0-depot\\packages\\PlotlyJS\\qhYQ5\\src\\kaleido.jl:65                                                                                             
> ┌ Warning: ErrorException("Could not start Kaleido process")                                                                                                                                                     
> └ @ PlotlyJS C:\\Users\\pkonl\\SublimeJulia\_1\_10\_0\\assets\\.julia-1.10.0-depot\\packages\\PlotlyJS\\qhYQ5\\src\\kaleido.jl:66

(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?

---

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [January 19, 2024, 10:30am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/25 "2024-01-19T10:30:48Z")

</div>

I like to do it manually. Undergrad students follow this set of [instructions](https://modernmacro.org/julia-and-pluto/). 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.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [January 19, 2024, 11:55am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/26 "2024-01-19T11:55:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 19, 2024, 4:41pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/27 "2024-01-19T16:41:27Z")

</div>

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

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/a/0a7bb1cee5cfac2d9cc7e3540dfc574541174c4f.png)

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:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/4/e4d041a4dd153f33e2be5bbb6654b225dc7697a5.png)  
Is this something new in Win 11? I thought it was supposed to work!?

Could this explains the difficulties with Kaleido?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/b/2ba5d1c05c56554f5465dcd2fa37c09294daefd3.png)

The backticks are the reason the path is constructed this way:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/b/3ba0d3ebe65a1c5cb3d66f13c383aa9b05f4174a.png)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/c/dceaa6e355c528c164309cfa11e96b21037e933d.png)

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [January 19, 2024, 6:21pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/28 "2024-01-19T18:21:25Z")

</div>

> [@PetrKryslUCSD](#):
>
> The folder name either without quotes or with `"` works fine. But as constructed in PlotlyJS kaleido.jl file with apostrophes (`'`), it fails!

I think this is just a display thing:

```julia
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

```

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [January 19, 2024, 6:44pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/29 "2024-01-19T18:44:24Z")

</div>

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](https://github.com/JuliaPluto/PlutoPlotly.jl/commit/38a7910fb0d80a9aef2b53a130b3811cc960ca2b) 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):

```julia-repl
(jl_AvCp4j) pkg> add PlotlyJS, Kaleido_jll@v0.1

```

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

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [January 19, 2024, 7:27pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/30 "2024-01-19T19:27:51Z")

</div>

> [@disberd](#):
>
> explicitly force the Kaleido\_jll library to version 0.1

seem to help others too: [https://github.com/plotly/Kaleido/issues/110](https://github.com/plotly/Kaleido/issues/110)

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [January 19, 2024, 7:38pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/31 "2024-01-19T19:38:08Z")

</div>

Yeah that was the issue that made me try that

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 19, 2024, 7:55pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/32 "2024-01-19T19:55:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jojob68](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jojob68](https://discourse.julialang.org/u/jojob68)\
**Post date:** [January 20, 2024, 4:15am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/33 "2024-01-20T04:15:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jojob68](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jojob68](https://discourse.julialang.org/u/jojob68)\
**Post date:** [January 20, 2024, 4:21am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/34 "2024-01-20T04:21:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jojob68](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jojob68](https://discourse.julialang.org/u/jojob68)\
**Post date:** [January 20, 2024, 4:24am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/35 "2024-01-20T04:24:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jojob68](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jojob68](https://discourse.julialang.org/u/jojob68)\
**Post date:** [January 20, 2024, 11:29pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/36 "2024-01-20T23:29:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [January 22, 2024, 7:19am UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/37 "2024-01-22T07:19:31Z")

</div>

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

> <https://github.com/JuliaPlots/PlotlyKaleido.jl/actions/runs/7572998261/job/20624122827?pr=14>

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [January 23, 2024, 4:06pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/38 "2024-01-23T16:06:48Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [March 5, 2024, 5:57pm UTC](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853/39 "2024-03-05T17:57:51Z")

</div>

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](https://github.com/JuliaPlots/PlotlyJS.jl/issues/473#issuecomment-1979300463) github comment for more details.

[Previous page](https://discourse.julialang.org/t/plotlyjs-causes-errors-cant-figure-out-how-to-use-plotlylight-how-to-use-plotly-from-julia/108853.md?page=1)
