Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

the program can not quit normally when I import native python package, for example: numpy#1746

Unanswered
yunzhizhou asked this question inQ&A
Discussion options

Environment

  • Pythonnet version: 3.0.0-preview2022-02-03
  • Python version: 3.8.10
  • Operating System: Windows 11
  • .NET Runtime: 6.0.200

Details

  • Describe what you were trying to get done.

    when I import the python package which is not native, I press Ctrl + C, the program will normally quit;
    but I import the python package which is native, for example: numpy ; I press Ctrl + C, the progrram will not quit.

  • Press Ctrl + C, normaly quit.

usingPython.Runtime;Environment.SetEnvironmentVariable("PATH",Path.GetFullPath(@"C:\\Users\\admin\\anaconda3\\envs\\pm3env"),EnvironmentVariableTarget.Process);PythonEngine.PythonHome="C:\\Users\\admin\\anaconda3\\envs\\pm3env";using(Py.GIL()){// dynamic np = Py.Import("numpy");// Console.WriteLine(np.cos(np.pi * 2));dynamicos=Py.Import("os");Console.WriteLine(os.listdir());}PythonEngine.BeginAllowThreads();Console.WriteLine("press Ctrl+C to quit");Console.ReadKey();
  • press Ctrl + C, not work.
usingPython.Runtime;Environment.SetEnvironmentVariable("PATH",Path.GetFullPath(@"C:\\Users\\admin\\anaconda3\\envs\\pm3env"),EnvironmentVariableTarget.Process);PythonEngine.PythonHome="C:\\Users\\admin\\anaconda3\\envs\\pm3env";using(Py.GIL()){dynamicnp=Py.Import("numpy");Console.WriteLine(np.cos(np.pi*2));}PythonEngine.BeginAllowThreads();Console.WriteLine("press Ctrl+C to quit");Console.ReadKey();
You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@yunzhizhou
Converted from issue

This discussion was converted from issue #1702 on March 30, 2022 13:53.


[8]ページ先頭

©2009-2025 Movatter.jp