Running Julia inside Blender through VSCode (using PythonCall/JuliaCall)

Hi all, I’ve been using a workflow that I came up with that consists of using Blender through its GUI and programmatically with Julia at the same time.

I usually develop in Julia using VSCode and its “execute line” and “execute cell” commands, so I was able to do that but with Julia running inside the Python that is running inside Blender, which allows me to interface with Blender itself through the Blender Python API (bpy module).

I’m dropping in here the instructions to set up such a workflow since this can be helpful to someone else or someone can even improve the usability of this.

Running Julia inside Blender through VSCode (using PythonCall/JuliaCall)

Install Blender

  • Install Blender into a user folder (any folder where user has rights to write). This allows us to install Python packages with Blender’s pip into Blender’s internal Python “site-packages” folder.

Install JuliaCall within Blender Python environment

  • Open Blender and run this on the Blender’s Python console:
    import pip
    pip.main(['install', 'juliacall'])
  • This needs to be done only once on each new Blender installation.

Connect a VSCode session to a Blender instance

  • Open VSCode.
  • Execute Blender from some terminal (may be a VSCode integrated terminal). This allows us to see Julia output there.
  • In VSCode, call the command Julia: Connect external REPL.
  • Copy the generated code and paste it into the indicated line of the following code
    c = r'''
    import sys
    sys.ps1 = '>>> ' # make PythonCall believe that Python is interactive so that display uses terminal size
    import juliacall
    def julia_work():
        return 0.02
    julia_timer =, persistent=True)
  • Copy the entire code above, paste it and run it on the Blender’s Python console.
  • Check terminal for feedback and VSCode notification for successful connection.


  • From now on, Julia code executed on that VSCode session with Julia: Execute... commands will run inside Julia inside Python inside Blender.
  • That code can be related to package and environment management, using the Pkg module, for example:
    import Pkg
  • Most useful, we can now call back into Blender from Julia!:
    using PythonCall
    bpy = pyimport("bpy")
    scn = bpy.context.scene
    objnames = [ for obj in scn.objects]
  • Blender GUI will still be usable and responsible, although it can freeze while Julia is doing computations.

Cool! Could you make a PR to link to this post from the PythonCall FAQ please? PythonCall.jl/ at main · cjdoris/PythonCall.jl · GitHub

Can you explain julia_work? Is it to keep Julia’s event loop going?

It seems that Python’s main thread (with GIL) is the Blender GUI thread too. So when something in Python is running the GUI is blocked and vice versa. As far as I understand the Julia main thread when starting through JuliaCall is the same one as Python. So no computation in Python or in Julia can constantly permanently hold the thread execution or the other parts will freeze.

julia_work is a callback that is set to be called by Blender with 0.02 secs timer interval. juliacall.Main.sleep(0.001) allows Julia schedule do its computations. I’ve tried juliacall.Main.yield() but that didn’t work. These times have been tunned empirically.

Done Add link in to instructions to run Julia within Blender by cdsousa · Pull Request #288 · cjdoris/PythonCall.jl · GitHub. I’m not sure if that was what you had in mind. Feel free to completely reformulate it.