Closed
Description
We are trying to support algorithms written in python in QuantConnect/Lean (which is written in C#).
So far, we were able to accomplish that locally in Windows. However, we have to make it work in a docker container in order to launch algorithms in our servers, but we could't make pythonnet work in that environment.
Here are the steps we are following:
- Run a container:
docker run -it quantconnect/lean:foundation /bin/bash
- Please checkout what system configuration quantconnect/lean:foundation has here.
- Install python:
apt-get update
apt-get install -y libglib2.0-dev python-all-dev python-pip git
pip install --upgrade pip && pip install pandas scipy numpy
- Install pythonnet
pip install git+https://github.com/pythonnet/pythonnet
After that, we ran the three winforms demos. All throw the same exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception.
at System.Windows.Forms.Control..ctor () [0x00014] in <5d999439b3404adfac86e7eebb5f00d6>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <5d999439b3404adfac86e7eebb5f00d6>:0
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in <5d999439b3404adfac86e7eebb5f00d6>:0
at System.Windows.Forms.Form..ctor () [0x00012] in <5d999439b3404adfac86e7eebb5f00d6>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
Finally, we ran the example of embedding Python in .NET from pythonnet README:
mcs /reference:Python.Runtime.dll test.cs && mono test.exe
that yields the following exception:
Unhandled Exception:
System.EntryPointNotFoundException: Py_IsInitialized
at (wrapper managed-to-native) Python.Runtime.Runtime:Py_IsInitialized ()
at Python.Runtime.Runtime.Initialize () [0x0000d] in <3b52ecce105142dc9f5c47b1d8f64b0e>:0
at Python.Runtime.PythonEngine.Initialize () [0x00014] in <3b52ecce105142dc9f5c47b1d8f64b0e>:0
at Python.Runtime.Py.GIL () [0x0000a] in <3b52ecce105142dc9f5c47b1d8f64b0e>:0
at Test.Test.Main (System.String[] args) [0x00000] in <d894aae141fa4a98b826174854b8bf77>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.EntryPointNotFoundException: Py_IsInitialized
at (wrapper managed-to-native) Python.Runtime.Runtime:Py_IsInitialized ()
at Python.Runtime.Runtime.Initialize () [0x0000d] in <3b52ecce105142dc9f5c47b1d8f64b0e>:0
at Python.Runtime.PythonEngine.Initialize () [0x00014] in <3b52ecce105142dc9f5c47b1d8f64b0e>:0
at Python.Runtime.Py.GIL () [0x0000a] in <3b52ecce105142dc9f5c47b1d8f64b0e>:0
at Test.Test.Main (System.String[] args) [0x00000] in <d894aae141fa4a98b826174854b8bf77>:0
Metadata
Metadata
Assignees
Labels
No labels