Hi. Before I begin, let me say I couldn’t find the “how to ask for help” post, so I hope I’m providing sufficient information.
I made some scripts leveraging pyRevit - first by simply modifying a native pyRevit script, then eventually creating a folder for my extension and telling pyRevit to include that folder path. So far, so good.
I moved my extension to %AppData%\pyRevit\Extensions (a first step toward eventually helping my coworkers install it on their machines). Most scripts still worked, but some generated the error “AttributeError: ‘module’ object has no attribute ‘ResourceReferenceKeyNotFoundException’”. So I moved my extension back to its original folder and pointed pyRevit back to that folder once again – but that error continued! (By the way, I had used this script many times earlier during this same day without any issue.)
Feeling lost, I turned to ChatGPT, whose advice led me to adding the following code to one of my scripts, right after the import clr section:
import System
from pyrevit import framework as _fw
if (hasattr(System, ‘Windows’)
and hasattr(System.Windows, ‘ResourceReferenceKeyNotFoundException’)
and not hasattr(_fw.wpf, ‘ResourceReferenceKeyNotFoundException’)):
_fw.wpf.ResourceReferenceKeyNotFoundException = System.Windows.ResourceReferenceKeyNotFoundException
This got that script working again (good) though I don’t fully understand why (bad). However, today I noticed a new problem: one of pyRevit’s own functions – Modify->Renumber – is now also generating this error.
At ChatGPT’s suggestion, I closed Revit and deleted the %APPDATA%\pyRevit folder, then restarted Revit but the problem remains. Here’s what I get:
IronPython Traceback:
Traceback (most recent call last):
File "C:\Users\j.hutchings\AppData\Roaming\pyRevit-Master\extensions\pyRevitTools.extension\pyRevit.tab\Modify.panel\edit2.stack\ReNumber.pushbutton\script.py", line 415, in <module>
File "C:\Users\j.hutchings\AppData\Roaming\pyRevit-Master\pyrevitlib\pyrevit\forms\__init__.py", line 720, in show
File "C:\Users\j.hutchings\AppData\Roaming\pyRevit-Master\pyrevitlib\pyrevit\forms\__init__.py", line 677, in __init__
AttributeError: 'module' object has no attribute 'ResourceReferenceKeyNotFoundException'
Script Executor Traceback:
System.MissingMemberException: 'module' object has no attribute 'ResourceReferenceKeyNotFoundException'
at Microsoft.Scripting.Runtime.LightExceptions.ThrowException(LightException lightEx)
at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run7[T0,T1,T2,T3,T4,T5,T6,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`9.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run9[T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
at CallSite.Target(Closure, CallSite, CodeContext, Object, Object, Object, Object, Object, Object)
at IronPython.Runtime.Types.PythonType.FastTypeSite`5.CallTarget(CallSite site, CodeContext context, Object type, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at Microsoft.Scripting.Interpreter.DynamicInstruction`8.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run7[T0,T1,T2,T3,T4,T5,T6,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`9.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run7[T0,T1,T2,T3,T4,T5,T6,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
at Microsoft.Scripting.Interpreter.DynamicInstruction`7.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run6[T0,T1,T2,T3,T4,T5,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at Microsoft.Scripting.Interpreter.DynamicInstruction`6.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at Microsoft.Scripting.Hosting.CompiledCode.Execute(ScriptScope scope)
at PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)
Revit:
25.4.41.14
20251111_1515(x64)
2025.4.4
pyRevit:
6.0.0.26032+2145
I would like to know a) how to solve this, and b) what did I do wrong to cause this to happen in the first place? Many thanks for any assistance ![]()
[As something probably unrelated but strange, after running Revit for the first time after deleting %APPDATA%\pyRevit, every time I opened a file I got a pyRevit popup saying “Document Opened” followed by the document path; also there was a new panel in my interface with some kind of a pyRevit test button. After closing Revit and restarting it, both of these behaviours are gone … as mysteriously as they had arrived! I can only assume some kind of test/trace mode was running, perhaps due to a toggle that hadn’t yet been set during that first run of Revit?]