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

Py.Import("numpy") error:Original error was: cannot import name 'Sequence' from 'collections' (D:\ProgramData\anaconda3\Lib\collections\__init__.py) #2506

Copy link
Copy link
@vc815

Description

@vc815
Issue body actions

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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