C # uses python net technology, and cannot run programs on other PC after packaging

再辰 王 0 Reputation points
2023-07-05T20:14:01.3133333+00:00

The program can run on my computer, and the packaged program needs to add a Python package under the. exe path to run.

When I run the packaged. exe on another computer, I can't succeed in any way.

I have changed to a relative path and read python38.dll. I don't know why it failed.

public Form1()         
{             
	try             
	{                 
		// Runtime.PythonDLL = Path.Combine(Environment.GetFolderPath(                 	//Environment.SpecialFolder.LocalApplicationData),                 
//str + @"\Python\python38.dll");                 
		Runtime.PythonDLL = Environment.CurrentDirectory + @"\Python\python38.dll";                 	InitializeComponent();                 
		PythonEngine.Initialize();                 
		PythonEngine.BeginAllowThreads();             
	}catch(Exception e)             
	{                 
		throw;             
	}         
}

Snipaste_2023-07-06_04-04-06

Snipaste_2023-07-06_04-05-29

Developer technologies .NET Other
Developer technologies C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.