-4

Background

I was looking for something like IronPython for my C# app, but supporting numpy packages. I decided to give a try to Pythonnet. Everything works fine as long as I'm on my machine with Python installed. But when I deploy my app, and try to start it on another machine, it crashes. My idea is that, Pythonnet is not deployed inside generated exe. This mean that it is usless for me.

Here an MWE:

var input1 = new double[,] { { 15 }, { 274.5 } };
Runtime.PythonDLL = @"C:\pythonx86.3.11.2\tools\python311.dll";
PythonEngine.Initialize();
dynamic os = Py.Import("os");
dynamic sys = Py.Import("sys");
sys.path.append(os.getcwd());
dynamic test = Py.Import("Test");
int r1 = test.Test_fun(input1);
PythonEngine.Shutdown();

And Test.py

import numpy as np
import numpy.matlib

def Test_fun(x1):

  Q = np.size(x1,1) # samples
  
return Q

Question:

Is there any way to makes the deployed .exe work on machine without python installed?

Karls
  • 731
  • 7
  • 17

1 Answers1

2

You can bundle Python with your app. Just copy it over, no installation required.

LOST
  • 2,956
  • 3
  • 25
  • 40
  • I can, but it is like extra 150 mb. Is there any way to include "lite" version with only core and numpy? – Karls Feb 24 '23 at 17:03