Problem with running blender as a python module

Hi

I successfully built blender (2.8) as a python module on manjaro, following instructions here:


but when i try to import bpy in python I get the following error:

Python 3.7.3 (default, Mar 26 2019, 21:43:19)
[GCC 8.2.1 20181127] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import bpy
Traceback (most recent call last):
File “”, line 1, in
ImportError: /usr/lib/libjemalloc.so.2: cannot allocate memory in static TLS block

can anyone shed some light on this, i’m a bit lost.
thanks.

You can try building with WITH_JEMALLOC=OFF.

thanks brecht
as i’m rather new to this, would this be the correct usage:

sudo make BUILD_CMAKE_ARGS="-D WITH_JEMALLOC=OFF"

tried this and several other things (make bpy, and disabling WITH_MEM_JEMALLOC), but no dice.
installation runs without errors, files get installed in /usr/lib64/python3.7/site-packages, but as soon as i try to import in python, i get the error:

ImportError: /usr/lib/libjemalloc.so.2: cannot allocate memory in static TLS block

this is not critical as i’m just playing around with the stuff, but if anyone has any clue …

thanks!

try

cmake -DWITH_JEMALLOC=OFF .
make

in your build folder.

thanks LazyDodo

still the same error.

i started from scratch this time, just to make sure i didn’t mess up something else before.

  • i cloned the blender repository and built blender without any errors, and got a working blender build
  • i then built blender as a python module using make bpy, again without any errors
  • then ran cmake -DWITH_JEMALLOC=OFF . in /build_linux_bpy, which gave me this warning:

CMake Warning:
Manually-specified variables were not used by the project:
WITH_JEMALLOC

  • after running make and make install the problem persisted

  • then tried the same with cmake -DWITH_MEM_JEMALLOC=OFF ., but i’m still getting the same error when i try to import bpy in python

anything else i can try?
thanks

Oops sorry about that, the flag is called WITH_MEM_JEMALLOC .

no worries :wink:
tried that too, but am still getting the same error when importing bpy in python

1 Like

One thing that worked for me was for:
/home/tibicen/Dokumenty/blender-git/blender/build_files/cmake/config/bpy_module.cmake
to add line (free this line out of if statement):
set(WITH_MEM_JEMALLOC OFF CACHE BOOL "" FORCE)
cause if statement for “Linux” system doesn’t work in all cases. I’m using Fedora 30.

if(CMAKE_SYSTEM_NAME MATCHES "Linux") doesn’t work for me…

1 Like

Yes, this was my problem on Manjaro:
Once I added set(WITH_MEM_JEMALLOC OFF CACHE BOOL "" FORCE) manually, and re-ran ‘make bpy’, it worked :slight_smile:

Thanks

Just wanted to mention a workaround that doesn’t involve rebuilding without jemalloc support:

LD_PRELOAD=/usr/lib/libjemalloc.so.2 python