# Invalid drivers aren't shown and can't be deleted

I have following problem.

With the minecraft rig works everything fine (thomas rig) but when I open the console there are displayed invalid drivers of already deleted objects. How can I delete them? Even if select everything in the outliner and then go to the driver editor these aren't displayed. Therefore I can't delete them. So how can I delete them? I am really struggling with that.

Remove, since removed shape-key drivers.

From pic in question appears they are shape key drivers, which remain if a keyblock is removed, renamed (To reproduce, add a shapekey "Key 1", give it a driver, delete the shapekey. Then add a new key, and since its name is "Key 1" bingo it has a driver... )

Code to remove invalid path shape key drivers.

import bpy

for sk in bpy.data.shape_keys:
if not sk.animation_data:
continue
bung_drivers = []
# find bung drivers
for d in sk.animation_data.drivers:
try:
sk.path_resolve(d.data_path)
except ValueError:
bung_drivers.append(d)
# remove bung drivers
while bung_drivers:
sk.animation_data.drivers.remove(
bung_drivers.pop()
)


Generic, for all ID types

Loop over all ID types in the data of the blend and remove any driver whose path does not resolve.

import bpy
from bpy import data
from bpy.types import bpy_prop_collection

colls = [
p for p in dir(data)
if isinstance(getattr(data, p), bpy_prop_collection)
]

for p in colls:
for ob in getattr(data, p, []):
continue
bung_drivers = []
# find bung drivers
try:
ob.path_resolve(d.data_path)
except ValueError:
bung_drivers.append(d)
# remove bung drivers
while bung_drivers:

• Hello batFinger, thanks for the help! I now have run the code and most of the errors are gone now. But there are still some errors about bone constraints like this: WARN (bke.anim_sys): C:\b\buildbot-worker-windows\windows_291\blender.git\source\blender\blenkernel\intern\anim_sys.c:2926 BKE_animsys_eval_driver: invalid driver - pose.bones["L.Leg_knee.009"].constraints["Copy Rotation"].mute[0] and how would i remove these then? thanks in advance :D Feb 20 at 16:39
• Back up first. Try replacing bpy.data.shape_keys with bpy.data.objects. (In theory "should" be able to roll this over all bpy.data collections) Feb 20 at 17:05