I want to access BPY in standard python console on windows 64bit operating system. I searched, and found this link "http://wiki.blender.org/index.php/User%3aIdeasman42/BlenderAsPyModule". I did all the steps. but unable to import BPY in my python IDLE, also version of both are same. It shows error which is :"

>>> import bpy

Traceback (most recent call last): File "<pyshell#1>", line 1, in <module>

import bpy

ImportError: dynamic module does not define init function (initbpy)

please help me. thanks

  • 1
    $\begingroup$ Which version of Python are you using? $\endgroup$
    – dr. Sybren
    Jan 2, 2018 at 9:40

2 Answers 2


I also ran into this problem. I think Python3.x is needed or see bullet points below for more information.

Failed: python -c "import bpy; print('hello');"

Worked: python3 -c "import bpy; print('hello');"

  • "get Python3.x-framework from Python.org and install it."
  • "The Python version requirements are the same with building a regular blender binary (if Blender us using Python3.5 then there is NO WAY to use another version - 2.7/3.2/3.4 will all fail)."

Source: https://wiki.blender.org/index.php/User%3aIdeasman42/BlenderAsPyModule


Same Hassle on Ubuntu.

As of a recent change circa a month or two ago my bpy build also started to fail importing with same error. (Test import from bin folder, after successful build, before install)

>>> from bin import bpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_bpy)

As the error message suggests, and confirmed by running

$ nm -D bpy.so | grep PyInit_bpy

returning nada, whereas would expect something like

0000000002146787 T PyInit_bpy

Getting the result above and finally importing were woohoo moments indeed.

This came after searching high and low, throwing back quite a few red herrings, grinding through numerous updates, and so many re-builds, finally came across a couple of leads on stack overflow.


You need to either use a plain C compiler, or force C linkage throughout your module with an extern "C" directive:

leading me to the python link flags. Image from cmake_gui

enter image description here

The generated value for cmake entry PYTHON_LINKFLAGS was

-Xlinker -export-dynamic


-Xlinker --export-dynamic -Xlinker -init=PyInit_bpy

fixed the issue for me and I can now import bpy in a python 3.8 shell.

$ python3.8
Python 3.8.2 (default, Apr  2 2020, 03:24:36) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bpy

I feel tho, that this is a bit "hackish".. anyone reading with a "cleaner" way to do same please edit into answer or add comment.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .