Blender 2.82 or later + python development environment notes


I want to prepare the development environment with Blender + python. Blender's built-in editor and console are difficult to use, so I want to use it from vscode I want to develop and debug my own add-on and easily check the behavior of the bpy function.


Basic information

You can't ʻimport bpy` by hitting blender's python directly. You need to run python via blender.

Open python console from command line

How can I run blender from command line or a python script without opening a GUI?

$ blender --background --python-console

Will bring up the python console.

Used in VSCode.

It seems that this area can be used.

Advanced content

Thank you.

High-speed data transfer with Blender's C ++ add-on (LuxBlend method)

[Blender] Automate Blender add-on testing with GitHub and Travis CI

Build Blender

If you want to do the above blender as module or something special, it will be quick to build from the source code.

After dropping the source code and the prebuilt binary of the dependent library, You can build it just by doing basic make. Don't forget to do git submodule. If I do not

file INSTALL cannot find

I get an error around the locale.

Building Blender itself doesn't take much time as there is a prebuilt binary on Ubuntu. It took about 5 minutes with Threadripper 1950X.


$ make headless

You can build without GUI.

Blender as module

There is a build that makes Blender itself a python module (

With this, you can ʻimport bpy` with your favorite python interpreter etc., so it is expected that development will progress, but Ubuntu has a high hurdle.

prebuilt doesn't work.

The build command itself is simple.

$ make bpy

(It calls cmake internally, so it's a good idea to take a look at its cmake settings.)

First, is linked with shared lib, but prebuilt libs has only .a. It seems to be relocatable, but the library of the system on which .a depends is also linked with .a. So I get an error when linking (eg libpng.a), libpng.a or gomp.a (OpenMP).

If libpng.a is entered with apt, it will go to /usr/lib/.., so once you delete it with apt, link it with libpng.a on the prebult libs side. You can solve it. However, libpng.a may not be erased in some cases, so it may be safe to build around Docker.

gomp (OpenMP) depends on the environment. If you have an environment such as CUDA, there is a high possibility that gomp will be installed related to gcc, and libgomp.a in / usr / lib / ... You will get a build fail trying to link.

This is difficult because if you remove gomp you also have to remove the gcc compiler package. After all it may be good to build with Docker.

Also, if you do not build with WITH_MEM_JEMALLOC turned off,

cannot allocate memory in static TLS block

Error appears when importing.

Looking at the CMake settings, it should be OFF for Linux, but for some reason it is not reflected.

Building dependent libraries from source ...

$ make deps

You can build the dependent libraries from source with.

With bashrc etc,

alias make=`make -j8`

If you try to build in parallel as such, compilation will fail, so it may be better to make sure that alias is not set in make before doing make deps, but in that case 1 It takes a long time to build because it only builds on the core. It may be a good idea to build in parallel in anticipation of compiling several times.

If you build the dependent libraries from scratch, yasm (why do you need an assembler ?! I use it in the video codec system), it conflicts with the system boost, and building LLVM from scratch is troublesome.

At least OpenVDB didn't build well around boost for some reason. If you don't use VDB, why not build off for now?

install add-on

Even if is successfully created and import does not crash, this time I get an error if there is no such thing as ʻio_xxx`. These will be add_on, so adding add_on should solve it. (add_on related is managed by another git repo)


Recommended Posts

Blender 2.82 or later + python development environment notes
Python package development notes
Python development environment construction
About Python development environment
python2.7 development environment construction
Development environment in Python
Python 3.4 or later standard pip
Notes on creating a python development environment on macOS Catalina
Organize your Python development environment
[ev3dev × Python] Build ev3dev development environment
[MEMO] [Development environment construction] Python
[For organizing] Python development environment
Ruby's `` like Python. 2.6 or later
Prepare Python development environment on Ubuntu
Run mruby with Python or Blender
Prepare your first Python development environment
[Python3] Development environment construction << Windows edition >>
Python development environment options for May 2020
Python development environment construction on macOS
Vim + Python development environment setting memo
Emacs settings for Python development environment
Install Python development environment on Windows 10
Emacs Python development environment construction memo
Checking the NAOqi Python development environment
Prepare Python development environment with Atom
Continuation ・ Notes on preparing the Python development environment on Mac OS X
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
Build an environment for Blender built-in Python
Python development environment for macOS using venv 2016
How to prepare Python development environment [Mac]
Python3 + venv + VSCode + macOS development environment construction
To reference environment variables in Python in Blender
Build Python development environment (pythonz, virtualenv, direnv)
The strongest Python development environment PyCharm's recommendation
Building a Python development environment for AI development
Windows + gVim + Poetry python development environment construction
The strongest Python integrated development environment PyCharm
Python scraping notes
Introduction to Python Let's prepare the development environment
Python study notes _000
Python environment construction
python environment settings
Build Python development environment with Visual Studio Code
Python beginner notes
python windows environment
Python> 3.14_1592_6535_8972> PEP515 (Python v3.6 or later possible writing style)
Python study notes_006
Environment construction (python)
[Python] Build a Django development environment with Docker
Blender 2.9 Python Extrude extrude
python C ++ notes
Build a Python development environment on your Mac
[Python] Web development preparation (building a virtual environment)
Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes
python environment construction
python development environment -use of pyenv and virtualenv-
Python --Environment construction
Python study notes _005
Python grammar notes
Python Library notes
Run pip install on MacOS Python 3.7 or later