How to use GLMakie in jupyter notebook?

Hi, I am studying julia from yesterday, and I met a question when using GLMakie and python together in jupyter notebook.

Then problem is that I can’t use ‘using Makie’ in my code. The error is in the picture below.

Also, I want to rotate my 3D plot, however, the Makie is always ‘not responding’ after I use ‘display(fig1)’.

Could you please help me with this? Thanks!

Best,
Ziyi

Do you have to call Julia methods from Python? Have you tried / want to use Julia directly? (Jupyter notebooks support native Julia code.)

Hi,
I don’t have to call Julia methods, but I used Julia directly and its doesn’t work.
For example, I just used ‘using GLMakie’ in a python3, but it has the same error in the picture above.
How do I use julia directly? Thanks!

Well using GLMakie is Julia syntax, which of course is not understood by the Python parser. If you want to use Julia syntax you have to use Julia rather than Python, i.e. run a Julia kernel in your Jupyter notebook (via IJulia)

1 Like

First, you have to download Julia for your system:

Next you have to add the IJulia package (the Julia backend for Jupyter).

Open Julia (by clicking on the application icon or open a terminal and type julia. This is the Julia REPL. Type ] and then add IJulia. This will link Julia to Jupyter.

Now you should be able to select Julia from the list of kernels.

There is a nice longer tutorial here: 1. Setting up Your Julia Environment — Quantitative Economics with Julia

which also has a section on using Jupyter in Visual Studio Code, which is quite nice. (Using only Jupyter is at the bottom of the tutorial at section 1.10)

Note
You have to use Julia syntax. In your example you are using Python, Numpy, and matplotlib syntax (like np.sin() and plt.figure()). Check out the Makie basic tutorials and examples for how to make plots: Makie homepage

1 Like

Thanks very much! It’s very clear!

1 Like