Building Blender with a different Python version

If you build Blender for devel­op­ment or street cred, you know how sys­tem updates can be a prob­lem sometimes.

I hit this a while ago when Arch updat­ed to Python 3.5 as soon as it came out. I asked around on #blender­coders with­out hop­ing much, but turns out you can actu­al­ly build Blender with Py 3.5. Even 3.6!

The trick

Delete all vari­ables start­ing with “PYTHON_” in CMakeCache.txt (hint: it’s in your build fold­er). Then run the fol­low­ing com­mand to regen­er­ate the CMake cache with the right Python.

cmake -DPYTHON_VERSION=3.5 ../blender

Remember to change it to the Python ver­sion in your sys­tem. Also, make sure to point the last argu­ment to the direc­to­ry where you keep Blender’s source.

Now you can do make as usu­al. If you want to make a debug build you can add this to the pre­vi­ous com­mand: -DCMAKE_BUILD_TYPE=DEBUG

Hope you found this use­ful too, thanks go to Campbell for help­ing me out with this.

All the posts you can read
TutorialsBlender, Hacking, Python03.09.2018



4 Comments

  1. Silithas(5 years ago)

    I had no cmakecache.txt in my blender folder.

    1. Diego Gangl(5 years ago)

      Hi! cmakecache.txt is cre­at­ed when run­ning cmake. If you haven’t run cmake yet there won’t be a cache file, so you can skip that step.

  2. Leo Plaw(2 years ago)

    Thanks! This was very helpful.
    I could­n’t get Blender to com­pile because the lat­est pull from the repos­i­to­ry brought a new Python ver­sion, but of course the vari­ables in my CMakeCache.txt were still set to the old version.

    I sim­ply changed all of the ver­sion num­bers to the cor­rect one and Blender com­piled successfully.

    1. Diego Gangl(2 years ago)

      Hey, glad it was useful!

Leave a Reply

Your email address will not be published.