Author Topic: PY plugin  (Read 2522 times)

0 Members and 1 Guest are viewing this topic.

igvk

  • Jr. Member
  • **
  • Posts: 17
  • Karma: 0
    • View Profile
PY plugin
« on: June 20, 2017, 11:29:59 AM »
Hi,
I tried to use PY plugin under WIn10x64, but it doesn't seem to initialize correctly.
It throws the following error when trying to execute command:
Code: [Select]
Action from plugin: C:\VoxCommando\Plugins\PY\PY.dll
Action ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
   at vcPlugin.iPy.execString(String strCode)
   at vcPlugin.Plugin.doAction(String[] parsedActions, String[] parsedParams)
And the following while reinitializing:
Code: [Select]
System.Reflection.TargetInvocationException: Failed to load language 'IronPython 2.7.5': Method not found: 'System.Collections.Generic.IEnumerable`1<!!0> Microsoft.Scripting.Utils.ReflectionUtils.GetCustomAttributes(System.Reflection.Assembly, Boolean)'. ---> System.MissingMethodException: Method not found: 'System.Collections.Generic.IEnumerable`1<!!0> Microsoft.Scripting.Utils.ReflectionUtils.GetCustomAttributes(System.Reflection.Assembly, Boolean)'.
   at IronPython.Runtime.Binding.PythonBinder.DomainManager_AssemblyLoaded(Object sender, AssemblyLoadedEventArgs e)
   at IronPython.Runtime.Binding.PythonBinder..ctor(PythonContext pythonContext, CodeContext context)
   at IronPython.Runtime.PythonContext..ctor(ScriptDomainManager manager, IDictionary`2 options)
   --- End of inner exception stack trace ---
   at Microsoft.Scripting.Runtime.LanguageConfiguration.LoadLanguageContext(ScriptDomainManager domainManager, Boolean& alreadyLoaded)
   at Microsoft.Scripting.Runtime.DlrConfiguration.LoadLanguageContext(ScriptDomainManager manager, LanguageConfiguration config)
   at Microsoft.Scripting.Runtime.DlrConfiguration.TryLoadLanguage(ScriptDomainManager manager, AssemblyQualifiedTypeName providerName, LanguageContext& language)
   at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageByTypeName(String providerAssemblyQualifiedTypeName)
   at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngineByTypeName(String assemblyQualifiedTypeName)
   at IronPython.Hosting.Python.GetEngine(ScriptRuntime runtime)
   at vcPlugin.iPy.initializeEngine()

Besides - is it possible to replace IronPytnon libraries with newer ones, will they be compatible?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: PY plugin
« Reply #1 on: June 20, 2017, 01:37:14 PM »
I'm not able to investigate this at the moment because I am travelling. I will be home by the end of the week.

In order to look into this we need to know what version of VoxCommando you are using.

It might also help to know what python code you are trying to execute.

We also need to know if you are using an unaltered version of VoxCommando with only the DLLs that were originally installed.

Whether or not you have another version of Python installed and possibly running could also be a factor although I do not think that it should be.

I am not sure what you mean by "while reinitializing".

As for updating libraries, I don't see why this would be a problem as long as they are intended for Python 2, but the best way to know is to try it.  Not all libraries work with Iron Python in any case.

igvk

  • Jr. Member
  • **
  • Posts: 17
  • Karma: 0
    • View Profile
Re: PY plugin
« Reply #2 on: June 20, 2017, 02:19:22 PM »
I tried the latest stable and beta version of VC (2.2.3.7). The result is the same.

I tried to execute the simplest code like: "result=5+5".

Yes, the DLLs are original.
I also tried to substitute IronPython.* and Microsoft.* DLLs from a newer IronPython version, but it didn't solve the problem.

When I wrote about reinitializing, I meant the command "Reinitialize Python" form the PY plugin menu.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2318
  • Karma: 47
    • View Profile
Re: PY plugin
« Reply #3 on: June 20, 2017, 03:36:16 PM »
I have installed VC2.2.3.7 (beta) from the download page on a Windows 10/64bit system and python in VC works fine out of the box.

I used the "PY.ExecString" action with parameter:  result=5+5  as first action and as second action  "OSD.ShowText"  {LastResult}
which give me the correct result of 10 in a OSD window.


this is the test command:


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.7-->
<command id="265" name="python test" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result=5+5</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>test python</phrase>
</command>
***********  get excited and make things  **********

igvk

  • Jr. Member
  • **
  • Posts: 17
  • Karma: 0
    • View Profile
Re: PY plugin
« Reply #4 on: June 20, 2017, 04:10:45 PM »
I think it's possible that some environment (like installed versions of Python in the system) affect this error.

Can it be so? I thought that VC had self-contained version that shouldn't depend on others.
But I'll try to uninstall other them, to be sure.

igvk

  • Jr. Member
  • **
  • Posts: 17
  • Karma: 0
    • View Profile
Re: PY plugin
« Reply #5 on: June 20, 2017, 04:47:28 PM »
Yes, it was it.
System installation of IronPython broke this function in VC.
After uninstall everything is ok.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2318
  • Karma: 47
    • View Profile
Re: PY plugin
« Reply #6 on: June 20, 2017, 04:59:38 PM »
Good to hear you have it solved - thanks for the feedback.
« Last Edit: June 21, 2017, 02:12:41 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: PY plugin
« Reply #7 on: June 20, 2017, 08:54:21 PM »
I think it's possible that some environment (like installed versions of Python in the system) affect this error.

Can it be so? I thought that VC had self-contained version that shouldn't depend on others.
But I'll try to uninstall other them, to be sure.

Yes VoxCommando has a self contained version of Iron Python that does not depend on another version being installed. But obviously it is possible that another version can interfere by loading conflicting versions of DLLs. Perhaps your other installation is adding DLLs to the Windows system path and VoxCommando is loading those DLLs by mistake. I don't know if there is anything I can do to prevent this from happening.