Blender stopped reading my functions in drivers

I had a pair of files *.blend with some animated objects and *.py with functions for drivers of those animated objects.
Everything worked excellent. I didn`t open those files for a couple of months. I do not remember whether I started working in the next version of Blender during this time (now I work in 4.1). But when I opened my file today I found out that I cannot write new functions in my *.py file. Syntax is ok, when I even copy my old functions and just change names I get this ‘Invalid Python Expression’ in every driver.
Why could this happen?

You need to check your driver functions if they are using modules that turned obsolete in python 3.11, or if the modules are installed in your new Blender environment (i.e. using pip).

From what I know, there hasn’t been any change in the drivers function system.

This is all I uses and it still works. But their absolute copies do not work! As I it was allowed to us only 20 functions in one file and 21st already will not work :slight_smile:

import bpy
from math import cos
from math import sin
from math import tan
from math import atan
from math import acos
from math import asin
from math import sqrt
from math import pi

What is the output in the Console, when you add the functions to the driver_namespace??

sorry, i am not sure that i understand. I see console, but nothing special in it…

What I wanted to say is that:
this function works fine:

def FindX_from_head(val):
return cos(val)

and this (just a new name!) - does not work

def Stamper(val):
return cos(val)

They both were added like this:
bpy.app.driver_namespace[‘FindX_from_head’] = FindX_from_head
bpy.app.driver_namespace[‘Stamper’] = Stamper

Main menu > Window > Toggle_System_Console

Errors are normally fully reported there.

Do you mean something like this?

Yes. But when you add the function to the drivers_namespace, it should also show some other error… (it should appear above the other errors, but your screenshot is trimmed)

All I can see in your screenshot is that there are some circular dependencies in your scene, and that Stamper was not found in the bpy.app.driver_namespace.

If you go to the Python Console Editor and type bpy.app.driver_namespace.keys(), Stamper is for sure not listed there.

You were right, there was no Stamper. I have found why. I resaved .blend file and somehow my .py file was resaved also. But .blend file still read functions from the first version of .py file. Where of course was no any Stamper function!
ufff

1 Like