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

Appearance settings
Discussion options

Environment

win11
python 3.10.9

Details

string pathToVirtualEnv = "D:\ProgramData\anaconda3";
Environment.SetEnvironmentVariable("PATH", pathToVirtualEnv, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("PYTHONHOME", pathToVirtualEnv, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("PYTHONPATH", $"{pathToVirtualEnv}\Lib\site-packages;{pathToVirtualEnv}\Lib", EnvironmentVariableTarget.Process);

Runtime.PythonDLL =$"{pathToVirtualEnv}\python310.dll";
PythonEngine.PythonHome = pathToVirtualEnv;
PythonEngine.PythonPath = $@"D:\ProgramData\anaconda3" +
$@";D:\ProgramData\anaconda3\Lib\site-packages" +
$@";D:\ProgramData\anaconda3\Lib;";
PythonEngine.Initialize();
using (Py.GIL())
{

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

}

error:
Python.Runtime.PythonException:“

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.10 from "C:\Users\ufona\Desktop\WindowsFormsApp1\WindowsFormsApp1\bin\x64\Debug\WindowsFormsApp1.exe"
  • The NumPy version is: "1.23.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: cannot import name 'Sequence' from 'collections' (D:\ProgramData\anaconda3\Lib\collections_init_.py)

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #2506 on November 09, 2024 10:12.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.