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

**URL:** https://discourse.julialang.org/t/running-julia-inside-blender-through-vscode-using-pythoncall-juliacall/96838
**Category:** Specific Domains
**Tags:** python, vscode, juliacall, pythoncall, blender
**Created:** [March 30, 2023, 11:24am UTC](https://discourse.julialang.org/t/running-julia-inside-blender-through-vscode-using-pythoncall-juliacall/96838 "2023-03-30T11:24:12Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![cdsousa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdsousa/32/215553_2.png) [@cdsousa](https://discourse.julialang.org/u/cdsousa)
#### Post date: [February 4, 2024, 12:58am UTC](https://discourse.julialang.org/t/running-julia-inside-blender-through-vscode-using-pythoncall-juliacall/96838/6 "2024-02-04T00:58:05Z")

</div>

I’ve found yet another much better way to use Julia within Blender.

The idea is to launch JuliaCall with Blender’s Python and with it launch a Julia REPL in Blender’s terminal.  
Hence, we get a Julia REPL which is running inside Python inside Blender and has full access to Blender bpy API.

To do that, we must execute Blender from a terminal and pass it a small Python script to be run:

`blender.exe --python blender_julia.py`

where `blender_julia.py` contents are: (update version here: [Julia inside Python inside Blender · GitHub](https://gist.github.com/cdsousa/d820d27174238c0d48e5252355584172))

```python
# install JuliaCall within Blender's Python environment (if not already installed)
import importlib
if importlib.util.find_spec('juliacall') is None:
    import pip
    pip.main(['install', 'juliacall'])

# set number of Julia threads to 1 (otherwise bpy usage will crash)
import os
os.environ["PYTHON_JULIACALL_THREADS"] = "1"

# load Julia with JuliaCall
import juliacall

# start Julia REPL in the terminal
juliacall.Main.seval('import REPL; import Pkg; Base.active_repl = REPL.LineEditREPL(REPL.Terminals.TTYTerminal(get(ENV,"TERM",""),stdin,stdout,stderr), true); Threads.@spawn :interactive REPL.run_repl(Base.active_repl, backend->(Base.active_repl_backend = backend));')

# load PythonCall and bpy Python module within Julia
juliacall.Main.seval('using PythonCall; bpy = pyimport("bpy")')

# schedule a Blender timer to allow Julia run
import bpy
def julia_work():
    juliacall.Main.sleep(0.01)
    return 0.01

julia_timer = bpy.app.timers.register(julia_work, persistent=True)

```

(the first run may take a while to install JuliaCall)

After that, we have a Julia REPL in the terminal where Blender is running. Additionally, we can connect to the VSCode Julia extension with its `Julia: Connect external REPL` command.

---

_[View the full topic](https://discourse.julialang.org/t/running-julia-inside-blender-through-vscode-using-pythoncall-juliacall/96838)._
