benlubas / molten-nvim

A neovim plugin for interactively running code with the jupyter kernel. Fork of magma-nvim with improvements in image rendering, performance, and more
GNU General Public License v3.0
608 stars 33 forks source link

[Help] Not able to use the command :MoltenOpenInBrowser (WSL) #228

Closed Abstruse-AK47 closed 2 months ago

Abstruse-AK47 commented 2 months ago

I am trying to run plotly graph i but when i whenever i run :MoltenOpenInBrowser i get this error Error detected while processing function MoltenTick[1]..remote#define#request: line 2: Error invoking '/home/madara/.local/share/nvim/lazy/molten-nvim/rplugin/python3/molten:function:MoltenTick' on channel 5 (python3-rplugin-host): error caught in request handler '/home/madara/.local/share/nvim/lazy/molten-nvim/rplugin/python3/molten:function:MoltenTick [[1]]': Traceback (most recent call last): File "/home/madara/.local/share/nvim/lazy/molten-nvim/rplugin/python3/molten/utils.py", line 11, in inner func(self, *args, **kwargs) File "/home/madara/.local/share/nvim/lazy/molten-nvim/rplugin/python3/molten/__init__.py", line 872, in function_molten_tick m.tick() File "/home/madara/.local/share/nvim/lazy/molten-nvim/rplugin/python3/molten/moltenbuffer.py", line 230, in tick self.open_in_browser(silent=True) File "/home/madara/.local/share/nvim/lazy/molten-nvim/rplugin/python3/molten/moltenbuffer.py", line 203, in open_in_browser subprocess.run([opencmd, filepath]) File "/home/madara/projects/SDV/.venv/lib/python3.12/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/madara/projects/SDV/.venv/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/madara/projects/SDV/.venv/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'xdg-open'

I dont know what to do , just want to open the browser to check the interactive plot. I am on Ubuntu (WSL)

Abstruse-AK47 commented 2 months ago

I was able to resolve this issue by adding this vim.g.molten_open_cmd = "wsl-open" in my config file but now only browser shows up nothing else comes on it.

benlubas commented 2 months ago

What are you running? and what do you expect to see as output?

Abstruse-AK47 commented 2 months ago

It's a simple example of a plot that generates an HTML output. But when I try to open it, it shows nothing.

https://github.com/user-attachments/assets/d8762347-cc2e-45df-8f2b-cba090cab6ca

but if i use vim-slime it works just fine.

https://github.com/user-attachments/assets/e7b5936b-a16d-499f-bf96-758ebf23ba1e

benlubas commented 2 months ago

Would you mind providing the code as text. Makes my life easier.

Abstruse-AK47 commented 2 months ago

Its's just a random example of a scatter plot from the Plotly website.

# x and y given as array_like objects
import plotly.express as px
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
fig.show()
benlubas commented 2 months ago
<No usable MIMEtype! Received mimetypes ['application/vnd.plotly.v1+json', 'text/html']>

There's a text/html mimetype, but it's not really standalone HTML, the standalone HTML throws an error. I'm pretty sure that's an issue with plotly.

The special application/vnd.plotly.v1+json type would need some extra code to be supported by molten. So this is similar to #142

Abstruse-AK47 commented 2 months ago

Sorry for the late reply. If that's something not supported, there's not much that can be done, so I'll close this for now.