From jared at quantconnect.com Mon Jul 9 17:13:14 2018 From: jared at quantconnect.com (Jared Broad) Date: Mon, 9 Jul 2018 17:13:14 -0400 Subject: [Python.NET] Tips for Debugging? Message-ID: Hello PythonNet Do you have any tips/experiences/tools for allowing debugging for a C#-pythonnet script? Thank you Jared -- Jared Broad www.quantconnect.com Phone-USA: +1 917 327 0556 *Democratizing Finance, Empowering Individuals* Facebook | Twitter | LinkedIn | Skype: jaredbroad We're recruiting! Join us and make your mark on the future of finance -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Tue Jul 24 19:13:01 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Wed, 25 Jul 2018 04:13:01 +0500 Subject: [Python.NET] Tips for Debugging? In-Reply-To: References: Message-ID: I wrote a debugging tutorial using PTVS here and further improvements are welcome! https://github.com/pythonnet/pythonnet/wiki/Various-debugging-scenarios-of-embedded-CPython On Tue, Jul 10, 2018, 2:13 AM Jared Broad via PythonDotNet < pythondotnet at python.org> wrote: > Hello PythonNet > > Do you have any tips/experiences/tools for allowing debugging for a > C#-pythonnet script? > > Thank you > Jared > > -- > Jared Broad > > www.quantconnect.com > Phone-USA: +1 917 327 0556 > *Democratizing Finance, Empowering Individuals* > Facebook | Twitter > | LinkedIn > | Skype: jaredbroad > > We're recruiting! Join us and make your mark on the future of finance > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lzr_walter at 163.com Wed Jul 11 21:28:34 2018 From: lzr_walter at 163.com (LZR) Date: Thu, 12 Jul 2018 09:28:34 +0800 (GMT+08:00) Subject: [Python.NET] there are something with my computer Message-ID: <7b62fcd6.2d4c.1648c1aa7f5.Coremail.lzr_walter@163.com> hello,there are something with my computer,I need your help when i run setup.py ,there are always CSC ,but i don't know how to deal with it thank you . ???????? -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 868B3CF7-0903-4673-8AF7-0ECC67072FC2.png Type: image/png Size: 26070 bytes Desc: not available URL: From alex at quantconnect.com Fri Jul 27 15:28:31 2018 From: alex at quantconnect.com (Alex Catarino) Date: Fri, 27 Jul 2018 20:28:31 +0100 Subject: [Python.NET] Fwd: Tips for Debugging? In-Reply-To: References: Message-ID: Hi pythonnet team, I followed your tutorials ( https://github.com/pythonnet/ pythonnet/wiki/Various-debugging-scenarios-of-embedded-CPython) and I could test two out of three scenarios (I couldn't get ptvsd to work). When I tested it on Lean, I've verified that we don't get much information with the mixed-mode cross-language debugger, so I extended your example with a mock Lean algorithm: https://github.com/QuantConnect/pythonnet/tree/debug First scenario - mixed-mode cross-language debugger (attached file: mixeddebugger.png): The debugger doesn't give us the information about the object if we click/mounse over on it or inspect it in Locals/Watch. We need to know what attributes it has to access them in "Immediate Window". Second scenario - python debugger (attached file: pythondebugger.png): The debugger does show the information. The issue with the python debugger is that as we are using threads in Lean, we need to detach and reattach on every iteration in this code snippet the emulates the OnData call: Task.Factory.StartNew(() => { algorithm.Run(); }).ContinueWith((ant) => { algorithm.Initialize(); }).ContinueWith((ant) => { algorithm.OnData(DateTime.UtcNow.ToString()); algorithm.OnData(DateTime.UtcNow.ToString()); algorithm.OnData(DateTime.UtcNow.ToString()); }).Wait(); I have tried to attach the debugger in different places in the python script. If I call it in module level, breakpoints are never hit in the algorithm. If I call it in Initialize, only breakpoints in Initialize are hit. And finally, if I call it in OnData, I need to detach and reattach on every OnData call from the block above. Best regards, Alex On Wed, Jul 25, 2018 at 12:13 AM, Denis Akhiyarov wrote: > I wrote a debugging tutorial using PTVS here and further improvements are > welcome! > > https://github.com/pythonnet/pythonnet/wiki/Various-debuggin > g-scenarios-of-embedded-CPython > > > On Tue, Jul 10, 2018, 2:13 AM Jared Broad via PythonDotNet < > pythondotnet at python.org> wrote: > >> Hello PythonNet >> >> Do you have any tips/experiences/tools for allowing debugging for a >> C#-pythonnet script? >> >> Thank you >> Jared >> >> -- >> Jared Broad >> >> www.quantconnect.com >> Phone-USA: +1 917 327 0556 >> *Democratizing Finance, Empowering Individuals* >> Facebook | Twitter >> | LinkedIn >> | Skype: jaredbroad >> >> We're recruiting! Join us and make your mark on the future of finance >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: mixeddebugger.PNG Type: image/png Size: 35463 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pythondebugger.PNG Type: image/png Size: 60462 bytes Desc: not available URL: From andrei.faber at gmail.com Sat Jul 28 12:31:53 2018 From: andrei.faber at gmail.com (Andrei Faber) Date: Sat, 28 Jul 2018 11:31:53 -0500 Subject: [Python.NET] PythonNet vs built-in functions Message-ID: <4e3b6757-8baf-1c00-3a1d-58d4ca17f22c@gmail.com> Hello, How do I call a _built-in_ function using PythonNet, for instance dir()? -- Best regards, Andrei Faber From mohamed.koubaa at ansys.com Mon Jul 30 12:43:26 2018 From: mohamed.koubaa at ansys.com (Mohamed Koubaa) Date: Mon, 30 Jul 2018 11:43:26 -0500 Subject: [Python.NET] Invoking a C# method with a python list Message-ID: Hello, I am using the 2.3 release branch. I have C# code like this: public class A { public A() {...} } public class B { public B() {...} public static void Func(IEnumerable input){ } } I want to pass in a python list to Func but get this error: >>> b=B() >>> b.Func([A(), A()]) Traceback (most recent call last): File "", line 1, in TypeError: No method matches given arguments I tried both IEnumerable and IList in the signature of 'Func'. I know that I can import System and create some .NET collection type and it works well. Did I miss anything? Is this usage pattern within the design goals of pythonnet? I assume this would have to be fixed in MethodBinder but I wanted to try asking here first. Thanks! Mohamed Koubaa -------------- next part -------------- An HTML attachment was scrubbed... URL: From viktoria.kovecses at imaginary-spaces.com Mon Jul 30 13:02:45 2018 From: viktoria.kovecses at imaginary-spaces.com (Viktoria Kovecses) Date: Mon, 30 Jul 2018 13:02:45 -0400 Subject: [Python.NET] Python.Net crash on assembly reload in Unity Message-ID: Hello, We are experiencing crashes when running Python.Net in the Unity 2018.2 game engine. Specifically, after modifying a C# script in Unity, an automatic reload is triggered which results in a crash in Py_Finalize. Here are the repro steps: 0. Make sure to call PythonEngine.Shutdown on domain unload (otherwise it crashes earlier). 1. Create a Unity project and add the compiled Python.Net files (clr.pyd and Python.Runtime.dll) to the Assets folder 2. In Unity Player Settings (Edit > Project Settings > Player), under "Other Settings", make sure "Api Compatibility Level" is set to ".NET 4.x", and "Scripting Runtime Version" is set to ".NET 4.x Equivalent" 3. In Assets, create the following C# script (HelloWorld.cs): ``` using UnityEditor; using UnityEngine; using Python.Runtime; class HelloWorld { [MenuItem("Python/Hello")] public static void CallHello() { using (Py.GIL()) { string script = "import clr\n" + "clr.AddReference('UnityEngine.dll')\n" + "import UnityEngine\n" + "UnityEngine.Debug.Log('hello world!')\n"; PythonEngine.Exec(script); } } } ``` 4. Run the script by selecting Python > Hello from the top menu --> This will log "hello world!" to the Unity console 5. Modify HelloWorld.cs script: change Hello to Hello 1 and trigger hot reloading of assemblies 6. run Python > Hello 1 --> Logs in the console 7. Modify HelloWorld.cs script: change Hello 1 to Hello 2: --> crash in dict_traverse (garbage collection during Py_Finalize). Does anyone know what could be causing the crash and/or how to fix it? Any help is appreciated. Thank you, Viktoria -------------- next part -------------- An HTML attachment was scrubbed... URL: