-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyRevitCPythonNotSupported #155
Comments
@jpdon2503 : I had the same error message, so I checked in the pyrevit source code at: if PY3 and not IRONPY340:
raise PyRevitCPythonNotSupported('pyrevit.forms') Since Ironpython in RPS 2.0.2 is Ironpython3.4.1, After going back to RPS 2.0.1 which has exactly the checked 3.4.0 IronPython version, ...BUT: from pyrevit import forms
user_input = forms.ask_for_string() you might get this error instead: 🤔 ... from pyrevit import forms
>>> user_input = forms.ask_for_string(default="default_", prompt="prompt_", title="title_")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\pyrevit_4.8.14\pyrevitlib\pyrevit\forms\__init__.py", line 3389, in ask_for_string
File "C:\ProgramData\pyrevit_4.8.14\pyrevitlib\pyrevit\forms\__init__.py", line 705, in show
File "C:\ProgramData\pyrevit_4.8.14\pyrevitlib\pyrevit\forms\__init__.py", line 667, in __init__
File "C:\ProgramData\pyrevit_4.8.14\pyrevitlib\pyrevit\forms\__init__.py", line 171, in __init__
File "C:\ProgramData\pyrevit_4.8.14\pyrevitlib\pyrevit\forms\__init__.py", line 194, in load_xaml
TypeError: LoadComponent() takes exactly 3 arguments (2 given) Where it seems like wpf.LoadComponent (or more precisely So if someone has suggestions to get the pyrevit.forms working on RPS, |
with latest pyRevit, on the develop-4 branch the issue has been resolved try changing the ipy engine for something newer than 2.7.7.0 you could use the wip installers of pyrevit to get the fix |
@jmcouffin thank for the quick feedback! 🙂 |
this error is a common one and due to the way the ironpython wpf is brought in. Depending on the way, it requires the CodeContext passed as well _ which is unwanted. Proper usgae of LoadComponent should be 2 args only. |
thank you for the explanation. |
Not sure, it will happen anytime soon, not like this year, I mean. |
I see. thank you for the estimation. so far tests on my end look promising - after removing all dependencies to rpw, most of our pyrevit buttons seem ready. 🙂 ( |
@jmcouffin thank you so much! |
ok, I spoke to soon: while does now work reliably on rps, it does not always on pyrevit. 🤔 |
Maybe a persistent engine is required? |
@jmcouffin what would this persistent engine look like? it seems like I have pyrevit.forms wpf reliably working now on this machine, for both rps (ipy3.4.0) and pyrevit(py3.4.0) :
import clr
clr.AddReference("IronPython")
import IronPython
wpf_dllpath = r"C:\ProgramData\pyrevit_4.8.14\bin\engines\IPY340PR\pyRevitLabs.IronPython.Wpf.dll"
clr.AddReferenceToFileAndPath(wpf_dllpath)
import wpf
BUT:
import clr
def show_clr_refs_filtered(search_text):
print("show_clr_refs_filtered:")
for ref in clr.References:
if search_text.lower() in ref.ToString().lower():
print(35*"-")
print(ref)
print(ref.Location)
print(35*"=")
show_clr_refs_filtered("wpf")
from pyrevit import forms
user_input = forms.ask_for_string(default="received_user_input")
print(user_input)
import wpf
print(wpf.LoadComponent.__doc__)
show_clr_refs_filtered("wpf")
import clr
wpf_dllpath = r"C:\ProgramData\pyrevit_4.8.14\bin\engines\IPY340PR\pyRevitLabs.IronPython.Wpf.dll"
clr.AddReferenceToFileAndPath(wpf_dllpath)
import wpf
print(wpf.LoadComponent.__doc__)
import clr
def show_clr_refs_filtered(search_text):
print("show_clr_refs_filtered:")
for ref in clr.References:
if search_text.lower() in ref.ToString().lower():
print(35*"-")
print(ref)
print(ref.Location)
print(35*"=")
show_clr_refs_filtered("wpf")
from pyrevit import forms
user_input = forms.ask_for_string(default="received_user_input")
print(user_input)
show_clr_refs_filtered("wpf") which is rather puzzling to me, since I assumed the pyrevit wpf dll referenced to in the second snippet, equally puzzling I find, that in pyrevit in both cases - the one with the error and the one without - but the errors with the message it would need 3 args. @jmcouffin or maybe @eirannejad : do you know what is going on there? |
ok and if for ipy340 engine as they are now in both contexts a module. so my interpretation is (please correct me if I am wrong): I assume the |
@jpdon2503 does the following resolve your error message?: for rps 2.0.1: in init.py import wpf: import clr
wpf_dllpath = r"C:\ProgramData\pyrevit_4.8.14\bin\engines\IPY340PR\pyRevitLabs.IronPython.Wpf.dll"
clr.AddReferenceToFileAndPath(wpf_dllpath)
import wpf you would need to replace |
I am using revit 2024 and revit python shell 2.0.2, i cant import forms from pyrevit( from pyrevit import forms) i get this error
Exception : System.Exception: PyRevitCPythonNotSupported
at Microsoft.Scripting.Interpreter.ThrowInstruction.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.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Runtime.Method.MethodBinding.SelfTarget(CallSite site, CodeContext context, Object target)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Microsoft.Scripting.Interpreter.FuncCallInstruction
5.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2) at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2) at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at IronPython.Runtime.Method.MethodBinding
1.SelfTarget(CallSite site, CodeContext context, Object target, T0 arg0)at IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
at Microsoft.Scripting.Interpreter.FuncCallInstruction
5.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 System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) 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 _check_name_wrapper$683(Closure , PythonFunction , Object , Object , Object , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at IronPython.Runtime.Method.MethodBinding
1.SelfTarget(CallSite site, CodeContext context, Object target, T0 arg0) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at Microsoft.Scripting.Interpreter.FuncCallInstruction
6.Run(InterpretedFrame frame)at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at IronPython.Runtime.PythonContext.Call(CodeContext context, Object func, Object arg0)
at IronPython.Runtime.Importer.FindAndLoadModuleFromImporter(CodeContext context, Object importer, String fullName, PythonList path, Object& ret)
at IronPython.Runtime.Importer.TryLoadMetaPathModule(CodeContext context, String fullName, PythonList path, Object& ret)
at IronPython.Runtime.Importer.ImportNestedModule(CodeContext context, PythonModule module, ArraySegment
1 parts, PythonList path, String scopeModuleName) at IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object from, String name) at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallInstruction
7.Run(InterpretedFrame frame)at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.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 Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle& exception)
The text was updated successfully, but these errors were encountered: