QuantConnect.pythonnet 2.0.39

pythonnet is a package that gives .NET programmers ability to integrate Python engine and use Python libraries.

Embedding Python in .NET

  • You must set Runtime.PythonDLL property or PYTHONNET_PYDLL environment variable, otherwise you will receive BadPythonDllException (internal, derived from MissingMethodException) upon calling Initialize. Typical values are python38.dll (Windows), libpython3.8.dylib (Mac), libpython3.8.so (most other *nix). Full path may be required.
  • All calls to Python should be inside a using (Py.GIL()) {/* Your code here */} block.
  • Import python modules using dynamic mod = Py.Import("mod"), then you can call functions as normal, eg mod.func(args). You can also access Python objects via PyObject and dervied types instead of using dynamic.
  • Use mod.func(args, Py.kw("keywordargname", keywordargvalue)) or mod.func(args, keywordargname: keywordargvalue) to apply keyword arguments.
  • Mathematical operations involving python and literal/managed types must have the python object first, eg. np.pi * 2 works, 2 * np.pi doesn't.

Example

using var _ = Py.GIL();

dynamic np = Py.Import("numpy");
Console.WriteLine(np.cos(np.pi * 2));

dynamic sin = np.sin;
Console.WriteLine(sin(5));

double c = (double)(np.cos(5) + sin(5));
Console.WriteLine(c);

dynamic a = np.array(new List<float> { 1, 2, 3 });
Console.WriteLine(a.dtype);

dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype: np.int32);
Console.WriteLine(b.dtype);

Console.WriteLine(a * b);
Console.ReadKey();

Output:

1.0
-0.958924274663
-0.6752620892
float64
int32
[  6.  10.  12.]

Resources

Information on installation, FAQ, troubleshooting, debugging, and projects using pythonnet can be found in the Wiki:

https://github.com/pythonnet/pythonnet/wiki

Mailing list https://mail.python.org/mailman/listinfo/pythondotnet Chat https://gitter.im/pythonnet/pythonnet

.NET Foundation

This project is supported by the .NET Foundation.

No packages depend on QuantConnect.pythonnet.

.NET 6.0

Version Downloads Last updated
2.0.50 0 2025/10/31
2.0.49 0 2025/10/21
2.0.48 1 2025/9/16
2.0.47 0 2025/8/14
2.0.46 0 2025/8/6
2.0.45 0 2025/7/31
2.0.44 0 2025/5/2
2.0.43 0 2025/5/1
2.0.42 0 2024/12/20
2.0.41 1 2025/11/19
2.0.40 0 2024/11/1
2.0.39 1 2025/11/10
2.0.38 1 2025/11/10
2.0.37 0 2024/5/14
2.0.36 0 2024/4/23
2.0.35 0 2024/4/19
2.0.34 0 2024/4/17
2.0.33 0 2024/4/16
2.0.32 0 2024/4/15
2.0.31 0 2024/4/12
2.0.30 0 2024/4/11
2.0.29 0 2024/3/18
2.0.28 0 2024/3/5
2.0.27 0 2024/3/4
2.0.26 0 2023/12/8
2.0.25 0 2023/11/21
2.0.24 0 2023/10/27
2.0.23 0 2023/10/19
2.0.22 0 2023/10/12
2.0.21 0 2023/7/11
2.0.20 0 2023/6/26
2.0.19 0 2023/6/26
2.0.18 0 2023/3/3
2.0.17 0 2022/8/24
2.0.16 0 2022/6/27
2.0.15 0 2022/5/17
2.0.14 0 2022/5/6
2.0.13 0 2022/5/2
2.0.12 0 2022/4/28
2.0.11 0 2021/12/27
2.0.10 0 2021/10/22
2.0.9 1 2025/11/19
2.0.8 1 2025/11/19
2.0.7 1 2025/11/19
2.0.6 1 2025/11/19
2.0.5 1 2025/11/19
2.0.4 1 2025/11/19
2.0.3 1 2025/11/19
2.0.2 1 2025/11/19
2.0.1 1 2025/11/19
2.0.0 0 2021/3/9
1.0.5.30 0 2020/3/31
1.0.5.29 0 2019/11/13
1.0.5.28 0 2019/11/12
1.0.5.27 0 2019/11/12
1.0.5.26 0 2019/10/15
1.0.5.25 0 2019/9/23
1.0.5.24 0 2019/9/10
1.0.5.23 0 2019/9/5
1.0.5.22 0 2019/9/5
1.0.5.21 1 2025/11/10
1.0.5.20 0 2019/4/23
1.0.5.19 0 2019/4/2
1.0.5.18 0 2019/3/27
1.0.5.17 0 2019/2/21
1.0.5.16 0 2019/2/20
1.0.5.15 0 2019/1/22
1.0.5.14 0 2019/1/18
1.0.5.13 0 2019/1/15
1.0.5.12 0 2018/8/27
1.0.5.11 0 2018/8/27
1.0.5.10 0 2018/8/24
1.0.5.9 0 2018/7/23
1.0.5.8 0 2018/7/16
1.0.5.7 0 2018/4/2
1.0.5.6 0 2018/4/2
1.0.5.5 0 2018/2/2
1.0.5.4 0 2017/12/29
1.0.5.3 0 2017/12/29
1.0.5.2 0 2017/11/29
1.0.5.1 0 2017/10/9
1.0.5 1 2025/11/19
1.0.4.8 0 2017/9/12
1.0.4.7 0 2017/9/8
1.0.4.6 0 2017/9/4
1.0.4.5 0 2017/8/21
1.0.4.4 0 2017/6/23
1.0.4.3 0 2017/6/23
1.0.4.2 0 2017/6/22
1.0.4.1 0 2017/6/22
1.0.4 1 2025/11/19
1.0.3.5 0 2017/6/1
1.0.3.4 0 2017/6/1
1.0.3.3 0 2017/6/1
1.0.3.2 0 2017/5/31
1.0.3.1 0 2017/5/31
1.0.3 1 2025/11/19
1.0.2.1 0 2017/5/25
1.0.2 1 2025/11/19
1.0.1.1 0 2017/4/11
1.0.0 1 2025/11/19