4
$\begingroup$

I would like to have a python notebook running on my localhost:8000 that i can execute bpy scripts with... and see the resulting change in my other monitor which is running blender.

Normally, I would have to import a script into the "Scripting - TextEditor" view and hit "run script". Is there a way to bypass this interface?

$\endgroup$
1

1 Answer 1

5
$\begingroup$

Updated answer

The Blender installation has a python version included. For windows version it is under the following location:

C:\Program Files\Blender Foundation\Blender {blender version}{blender version}\python\bin

Based on the pip installation method available here we can install the pip package manager as follows:

PS > curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
PS > $blenderFolder="C:\Program Files\Blender Foundation\Blender 3.5"
PS > $pythonPath="${blenderFolder}\3.5\python\bin\python.exe"
PS > $blenderPath="${blenderFolder}\blender.exe"
PS > & ${pythonPath} .\get-pip.py
PS > & ${pythonPath} -m pip install blender_notebook
... 
  WARNING: The scripts blender-notebook.exe and blender_notebook.exe
   are installed in 'C:\..\AppData\Roaming\Python\Python310\
   Scripts' which is not on PATH.
...
PS > & $env:USERPROFILE\AppData\Roaming\Python\Python310\Scripts\blender_notebook.exe install --blender-exec="${blenderPath}"
PS > & $env:USERPROFILE\AppData\Roaming\Python\Python310\Scripts\jupyter-notebook.exe

See also:

Previous answer

One of the most important things to be aware of is installing the correct version of the tools:

Using the current 2.91 Blender version we should use Python 3.7. We can install that using Anaconda3 2020.02 from exe, list of packages.

After that we need to install the blender kernel from here, using the following command in anaconda terminal:

python -m pip install blender_notebook
blender_notebook install --blender-exec="C:\Program Files\Blender Foundation\Blender 2.91\blender.exe"

Now, when we start Jupyter Notebook we can select blender kernel.

First, you need to import the Blender specific library bpy:

# blender related imports
import bpy

After that, we are able to use many examples, already available out there.

I've made an example Jupyter Notebook on this topic, available here

See the discussion and plans on updating blender's python version here.

Update:

Blender 2.93: Python was upgraded to version 3.9.1. link

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .