- Install current python3.7 version with pyenv (Ubuntu 20.04 ships with 3.8)
- Install with fPIC:
env PYTHON_CFLAGS=-fPIC pyenv install 3.7.8
- Install with fPIC:
- Install numpy globally for that version with pip
$ git clone https://git.blender.org/blender.git; cd blender
$ git checkout v2.82a
$ git submodule update --init --recursive
$ mkdir lib; cd lib; svn checkout https://svn.blender.org/svnroot/bf-blender/tags/blender-2.82-release/lib/linux_centos7_x86_64; cd ..
$ mkdir build; cd build
$ cmake .. -DWITH_PYTHON_INSTALL=OFF -DWITH_PYTHON_MODULE=ON -DWITH_INSTALL_PORTABLE=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_MEM_JEMALLOC=OFF -DPYTHON_ROOT_DIR=/path/to/.pyenv/versions/3.7.8/ -DCMAKE_INSTALL_PREFIX=/path/to/venv/lib/python3.7/site-packages/
$ make -j8
$ make install
Test with python -c "import bpy; bpy.ops.wm.save_as_mainfile(filepath='my.blend')"
- ImportError:
/usr/lib/x86_64-linux-gnu/libjemalloc.so.2: cannot allocate memory in static TLS block
- Temporary fix:
env LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 python -c 'import bpy'
- Temporary fix:
Install Blender as a python module into Blender python environment in a clean Ubuntu 20.04 :
sudo apt update -y
sudo apt install -y build-essential git subversion cmake libx11-dev libxxf86vm-dev libxcursor-dev libxi-dev libxrandr-dev libxinerama-dev libegl-dev
sudo apt install -y libwayland-dev wayland-protocols libxkbcommon-dev libdbus-1-dev linux-libc-dev
mkdir ~/blender-git
cd ~/blender-git
git clone https://git.blender.org/blender.git
mkdir ~/blender-git/lib
cd ~/blender-git/lib
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/linux_centos7_x86_64
cd ~/blender-git/blender
git submodule update --init --recursive
cd ~/blender-git/blender
sudo make bpy
copy bpy build with add-ons into blender internal python dist
sudo cp -a /~/blender-git/build_linux_bpy/bin/bpy /~/blender-git/lib/linux_centos7_x86_64/python/lib/python3.10/site-packages/
run from that distribution
~/blender-git/lib/linux_centos7_x86_64/python/bin/python3.10 -c "import bpy"
extend from here