I'm trying to speed up some erosion simulations (simulating 10's of thousands of raindrops) I have in python but I cannot get Blender to even import a cython created module. I've created a super simple example in hopes of figuring it out but haven't yet. Any Cython advice is welcome! I'm working with the 2.83 LTS version, using/compiling with python version 3.7.4, and I am using easycython to build my cython files.

I tried Dr. Sybren's answer but to no avail - Here's the python code:

bl_info = {
"name": "Test",
"description": "",
"author": "Zach Eastin",
"version": (0, 5, 1),
"blender": (2, 83, 0),
"location": "View 3D > Properties Panel",
"support": "COMMUNITY",
"category": "Mesh"

import bpy
from os.path import dirname,join
import sys
fpath = join( dirname(__file__),"simple.pyd" )
if fpath not in sys.path:
# import simple
from . simple import f

class MyClassName(bpy.types.Operator):
    bl_idname = "my_operator.my_class_name"
    bl_label = "My Class Name"
    bl_description = "Description that shows in blender tooltips"
    bl_options = {"REGISTER"}

    def execute(self, context):
        # print("Cy:",simple.f(3,4))

        print("Cy:", f(3, 4))
        return {"FINISHED"}

class PanelClassName(bpy.types.Panel):
    bl_idname = "panelname"
    bl_label = "Panelname"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    def draw(self, context):
        layout = self.layout

clss = [

def register():
    for cls in clss :

def unregister():
    for cls in clss :

if __name__ == "__main__":

And then my Cython code

def f(int x, int y):
    return x*y

Really any help would be sooo appreciated! Thanks in advance!

  • $\begingroup$ I've also tried adding fpath = join( dirname(__file__) ) instead of the actual pyd file and still nothing $\endgroup$ Feb 3, 2021 at 16:29
  • $\begingroup$ Are you still having trouble with this? I think the space in . simple in your import statement is invalid syntax. What platform are you running this on? $\endgroup$
    – Will Chen
    Jun 10, 2021 at 23:51
  • 1
    $\begingroup$ I just went to writing pure C and importing it into python as a module. If I remember correctly it worked if I ran it outside of Blender but once in Blender it wouldn't. $\endgroup$ Jun 11, 2021 at 3:08

1 Answer 1


you should have it in dll searches by means of environment variabl try os.environ['PATH'] += your_dll_directory or use os.add_dll_directory(path) for your C files. (whichever works - in my case the first one works)

or You can add the path manually to EnvironmentVariables PATH (if it contains dlls) and also add it to PYTHONPATH.

blender may crash in other cases.


You must log in to answer this question.

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