I compile and run Blender as a Python module in a Docker container. Everything worked flawlessly, but after a rebuild of the container (without changing anything), I suddenly get the following error when I import the bpy module:
Traceback (most recent call last):
File "/opt/bpy/lib/python3.9/site-packages/3.0/scripts/modules/addon_utils.py", line 351, in enable
mod = __import__(module_name)
ModuleNotFoundError: No module named 'io_scene_obj'
Interestingly, all of my code still runs. However, I’d still like to fix this ugly error.
Since I pinned the version of Blender (3.0.1) and its libraries (3.0) and changed nothing else about the Dockerfile, I suspect that something else must have changed. First I suspected Python, since its version increased from 3.9.9 to 3.9.10 after the rebuild, but I was able to rule that out by downgrading Python.
TBH, I’m not very experienced with the compilation of Blender, am I missing something? Alternatively, could I just exclude the io_scene_obj module, since I don’t use it anyhow?
So I guess that after a rebuild of the container, the message should be gone. Still, I’d like to pin the versions used for building. Perhaps you can point me into the right direction for that as well? Or should I start a new thread for that?
As I said initially, I already tried to pin the versions, but apparently it does not work correctly. The associated part of the Dockerfile looks like this:
ARG BLENDER_VERSION="v3.0.1"
ARG BLENDER_LIBRARY_VERSION="3.0"
...
# Clone a shallow copy of the blender sources
RUN mkdir -p /opt/blender-git/
WORKDIR /opt/blender-git/
RUN git clone https://github.com/blender/blender.git -c advice.detachedHead=false --depth 1 --branch ${BLENDER_VERSION}
WORKDIR /opt/blender-git/blender
RUN git checkout -b my-branch
## Checkout submodules
RUN git submodule foreach git checkout ${BLENDER_VERSION}
# Download a copy of the blender libraries
RUN mkdir -p /opt/blender-git/lib
WORKDIR /opt/blender-git/lib
RUN svn export https://svn.blender.org/svnroot/bf-blender/tags/blender-${BLENDER_LIBRARY_VERSION}-release/lib/linux_centos7_x86_64/
As you can see, I want to avoid having to download the complete git history, and I thought that the git submodule foreach git checkout ${BLENDER_VERSION} line would do the trick. Is there a better way?
I fixed the problem by replacing RUN git submodule foreach git checkout ${BLENDER_VERSION} (which, at closer inspection, did exactly nothing) with RUN git submodule update --init --recursive.