Logseq like Jupyter Notebook et similia

Logseq is dope. Once you get used to it, you want its functionalities everywhere.

If you are a user of both Logseq and Jupyter Notebook et similia you know what I mean when I say that it would be great to have Logseq functionalities in interpreted/interactive notebooks.

I would like so have pieces of code in blocks in Logseq interpreted and rendered like in Jupyter Notebook, R Studio, Posit.co, Quarto.org ecc.

Maybe a block like this in Logseq:

r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
 subplot_kw = {'projection': 'polar'} 
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])

could be rendered like this (example taken from quarto.org):

i.e. a piece of interactive HTML or just an image.

If you have any idea about this and how it could be implemented maybe with a Logseq plugin write it below.

What’s tricky in particular is interpreting languages like Python, R, Julia ecc using binaries that are available on our systems. But I would be happy even with a companion external tool that maybe manipulate the .md files and a Logseq plugin does the rendering.

Also it would be cool if some common languages like Python could access the page properties:: or even more data about the graph. Imagine running data analysis tools on your own knowledge graph from the same app (Logseq) you use to manage it.

CC @GaiusScotius


Absolutely on the same page here, excuse the pun!

What I would add, from R markdown running in R Studio, is the ability for code blocks in Clojure — the “native language” of Logseq — to be run in-process so that they have access to an API to navigate, query and amend the whole graph and can import data from external sources. This, I admit, carries the potential of inadvertently breaking the graph, but it is more flexible than having to construct a query and somehow export the results to an external process, as would be needed if the script was in another language. That said, I’d take the latter if that was an easier first step, with the caveat that {{query …}} needs to be able to do a graph walk.


Logseq + Python Jupyter hybrid would be an unbelievably powerful paradigm shift for TfT/PKM and beyond.

Yes, imagine if all Logseq data could be exposed.
This could process text.
But also reduces the need for spreadsheets, a current limitation.
And generally provide a convenient method of automation/templating.

This can be viewed similarly to the Logseq Queries

In terms of baby steps - preceding a full supercharged Logseq Jupyter hybrid…
I noticed there is a calculator mode (‘calc’) authored by @bensu

It would seem more natural and powerful to have an embedded python console, instead of some math calculation domain-specific language (DSL).

I hope someone capable is inspired to create this!

1 Like

Exactly my thought!

Personally I would like to:

  1. being able to run a code block by clicking on a button and also set certain block to autorun when the page is open.
  2. once run, switch between source code and the output, that being text, image, HTML widget etc, with a toggle like the table view for queries.
  3. being able to display the output in a placeholder everywhere else: inline in another block and even in other pages. If a page contain a placeholder run the relative code even if it’s on another page. And also pasting the output in a new child block of a specified block to keep a history of outputs.
  4. an API for popular languages like Python to access Logseq entities like blocks, pages, properties and so on, including being able to tell on which page the user is when run and on which page the source code is.

Anything else?

  • A copy of the raw stream of Logseq in a FIFO file, as output
  • A FIFO file as input for the Logseq Plugin Core API.
1 Like

It would be great to have such a feature in Logseq!
@alex0 Do you know if it is possible now somehow to embed Jupyter Notebook files (local or from GitHub) in Logseq and search inside them?

1 Like

I know someone did it: Running Jupyter Notebook inside Logseq - YouTube

(to be clear this is not what this thread is about)

1 Like

What do you mean by “raw stream of Logseq”? And what do you want to achieve?

  1. ability to run blocks through external commands. Alternatively a simple way to call a Python function on a regular block or part of a block without having to set the block to be a source block. This could be used to insert information. Something like /python fun to run fun on the rest of the block.

@alex0 just out of curiosity, what interesting specific use case examples do you have?

What comes to my mind is querying Logseq blocks and doing some special kind of visualization with the data (habit tracking, mood tracking, water intake tracking, etc).

Interfacing code with Logseq objects is an additional nice thing to have to do also the things you mentioned.

But the main point for me is to partially replace tools like Jupyter notebooks. As I said, I like so much Logseq features like [[wikilinks]], block embedding etc that I would like them when using Jupyter too. So the simpler thing is to make Logseq able to provide basic Jupyter functionalities.

Also there is a tool called Quarto.org that can compile Markdown documents that embed code into beautiful papers or interactive HTML pages or even multi-page sites.

So using Logseq as a simple Jupyter and then combine it with Quarto could lead to an awesome publishing tool.


Excuse me, that was almost thinking out loud writing, and probably the wrong context in which to put it.

I was thinking of a FIFO file to capture the stream from the hook point in charge of reading the block data when a new block inserts or block changes, and another FIFO file to point to the hook in charge of save block when it receives valid block data, for example. That is, before the API of the Developer Plugins layer…

On the other hand, being able to access the API from an external application would also be interesting. Isn’t it?

Yeah definitely and since most programming languages can call shell commands one could call a Logseq one, though it would seem a bit strange to call it from a code block inside Logseq itself.

I’d prefer libraries for popular languages and keep the code as much idiomatic as possible, don’t you think so?

Just for the reference (and future searching) - this idea is pretty much doing literate programming such as done in Emacs org-mode also (came here searching for that capability in logseq)…


I am thinking about this for a while now as well and interested in exploring this.

From the discussion, I see two directions:

  1. Having a python API accessible from within logseq to access logseq itself. I think this could be done with Pyodide, loading the python interpreter within the logseq electron app and adapt to the logseq javascript API. I have tested pyodide in logseq and it works. Not sure though how hard the bridging is.
    I suppose you could do the same of course with JavaScript directly, having code blocks of JavaScript that are evaluated on demand with access to the logseq API. Perhaps there is Clojure already exposed?

  2. Connecting to a Jupyter Server and run code in a Jupyter kernel, basically replacing Jupyter Notebook with a logseq frontend. I have created an experimental plugin for that:


Still very very rudimentary though. Jupyter also has a lot of intricacies so this might be bumpy road ahead.

For both versions a lots of questions:

  • where to read code from? code sections? read children as well?
  • where to put the output? inline? child block? within a code section or plain text? replacing the code?
  • how to display various formats? HTML, Images, stdout and stderr (print), …
  • how to show status and manage kernels?

Maybe two options: render the output instead of the code (kinda like query results) and write the output in a specified block (the one below by default)?

Should this be turned into a feature request so people can vote on it?

1 Like

More than a request this is supposed to be a space to discuss ideas. There is not a single solution but multiple approaches and very different levels of integration, supported languages and tools etc.

So I would like to gather here what people come up with, no matter what: just let “Logseq+Jupyter” inspire you.

1 Like

I’d like to +1 for Quarto as it is interoperable with Rstudio…which is my use case.


Original idea here

tl;dr: While jupyter support would be great, I think being able to open them as Markdown would be fine. Is there any plugin that can do that?