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

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,041 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,195 questions
{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.