Compile Blender as Python Module

After much trial and error, I was finally able to compile Blender source code to a 64-bit Python module that can be used for developing Blender Python scripts in Eclipse. Below are the steps that finally worked for me.

  1. Install the latest Windows version of Cmake from
  2. Install Python version 3.3.x from
  3. Install the 64-bit SlikSVN subversion client from
  4. Setup MinGW-w64
    1. Download MinGW-w64 from here. Note that this must include gcc version 4.7.0 to work successfully.
    2. Extract the mingw64 directory from the downloaded file to the root of the C drive.
    3. Add C:\mingw64\bin to the system Path variable.
  5. Retrieve blender source code by running the following commands in a Windows command shell:

    mkdir blender
    cd blender

    svn checkout blender

    svn checkout lib/mingw64

  6. Configure blender by running the following commands:

    mkdir cmake-build
    cd cmake-build


  7. Make blender by running the following command:

    mingw32-make install
  8. Run the following commands to install the Blender python modules:

    copy bin\bpy.pyd C:\Python33\Lib\site-packages\
    copy bin\*.dll C:\Python33\Lib\site-packages\
    del C:\Python33\Lib\site-packages\python33.dll
    xcopy /E bin\2.69 C:\Python33\2.69\
  9. Test the installation by running the following command:

    python -c "import bpy ; bpy.ops.render.render(write_still=True)"


Posted in Programming, Windows Tagged with: , , ,
10 comments on “Compile Blender as Python Module
  1. Larry says:

    Thanks a lot. It works!

  2. Gregory Bloom says:

    Thanks! I had nearly given up hope. This makes it possible to automate Blender from an external Python. This is probably a n00b question: Is there also a way to run the GUI for this build of Blender? Do I need different cmake flags to generate the GUI?

    • admin says:

      I am not an expert on this, but I think the answer is no due to the WITH_PYTHON_MODULE flag. In the CMakeCache.txt file it states the following:

      //Enable building as a python module which runs without a user
      // interface, like running regular blender in background mode (experimental,
      // only enable for development)

  3. Daniel says:

    I followed your instructions and it compiled successfully.

    But when running the python command I get the error:

    ImportError: DLL load failesd: %1 is not a valid Win32 application.

    • admin says:

      Daniel, I am wondering if you have compiled Blender as a 64-bit module, but are running a 32-bit version of Python. Try running the “python” command with no arguments to launch the interactive Python interpreter. It should display the python version as well as whether it is 32 or 64-bit.

  4. Daniel says:

    I installed 64bit python now and now I am getting the following errors:

    C:\Python33>python -c “import bpy;”
    Color management: using fallback mode for management
    BLF_lang_init: ‘locale’ data path for translations not found, continuing
    bpy: couldnt find ‘scripts/modules’, blender probably wont start.
    ImportError: No module named ‘bpy_types’
    ImportError: No module named ‘bpy_types’
    pyrna_srna_ExternalType: failed to find ‘bpy_types’ module
    ImportError: No module named ‘bpy_types’
    ImportError: No module named ‘bpy_types’
    pyrna_srna_ExternalType: failed to find ‘bpy_types’ module
    ImportError: No module named ‘bpy_types’
    pyrna_srna_ExternalType: failed to find ‘bpy_types’ module
    F0100 00:46:11.681632 5060] Check failed: !IsGoogleLoggingInit
    ialized() You called InitGoogleLogging() twice!

    • Stef says:


      I got the same problem as Daniel. Could you resolve this issue?


      • admin says:

        I’m wondering if the xcopy command at the end of step 8 didn’t run properly. This command copies files built in step 7 to the C:\Python33\2.69 directory.

        I was able to reproduce the errors reported by Daniel by deleting the 2.69 directory.

        Note that you should be in the cmake-build directory when running the xcopy command, or modify the xcopy command to specify an absolute path to bin\2.69 directory.

      • Ray says:

        I got the same problem with 2.77 on Mac OS X El Capitan

  5. Arnaud says:

    Great tutorial, I finally managed to install the blender module.
    It’s recognized by my IDE (PyCharm)
    Auto completion doesn’t seem to work: when I type “” (of course after having imported bpy) it’s unable to suggest anything, which is exactly why I wanted to install this module in the first place.
    Do you have any clue on what’s happening?

Leave a Reply

Your email address will not be published. Required fields are marked *