Import Error Pythonnet Window 10

2

Environment

  1. Pythonnet version: 2.4.0.dev0, installed from Master
  2. Python version: Python 3.6.6, Anaconda 3
  3. Operating System: Window 10, 64 bit
  4. Using virtual studio 2017 Community

Details

I had virtual environment set up.

1) pip list

(py36) C:\Users\User\Desktop>pip list
Package         Version
--------------- ----------
certifi         2018.8.13
click           6.7
cycler          0.10.0
kiwisolver      1.0.1
matplotlib      2.2.3
mkl-fft         1.0.4
mkl-random      1.0.1
numpy           1.15.0
Pillow          5.2.0
pip             18.0
pyparsing       2.2.0
PyQt5           5.11.2
PyQt5-sip       4.19.12
python-dateutil 2.7.3
pythonnet       2.4.0.dev0
pytz            2018.5
scipy           1.1.0
setuptools      40.0.0
six             1.11.0
visbrain        0.4.2
vispy           0.5.3
wheel           0.31.1
wincertstore    0.2

2) path and pythonpath before python initialize.

string path = @"D:\Anaconda3\envs\py36;" + Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
Environment.SetEnvironmentVariable("PATH", path, EnvironmentVariableTarget.Process);

Environment.SetEnvironmentVariable("PYTHONHOME", @"D:\Anaconda3\envs\py36", EnvironmentVariableTarget.Process); 

// initialize python engine
PythonEngine.Initialize();

3) set Amaconda in %PATH%

My Path

4) python path

(py36) C:\Users\User\Desktop>python --version
Python 3.6.6 :: Anaconda, Inc.

ReadMe works fine.

but when i typed like this in my C# program

using (Py.GIL())
{
     // import vispy
     dynamic myVispy = Py.Import("vispy");
     Console.WriteLine("hi vispy");
}

error message below Python.Runtime.PythonException: 'ModuleNotFoundError : No module named 'vispy''

stack trace :

 Python.Runtime.PythonException
  HResult=0x80131500
  Message=ModuleNotFoundError : No module named 'vispy'
  Source=Python.Runtime
  StackTrace:

would like to know how to solve this ? Thank You.

python
.net
conda
importerror
python.net
asked on Stack Overflow Aug 21, 2018 by STREETKILLER007 • edited Aug 22, 2018 by denfromufa

1 Answer

0

See this answer: Python.NET does not work with Anaconda or Miniconda. You need a fresh python install.

answered on Stack Overflow Aug 26, 2020 by bricx

User contributions licensed under CC BY-SA 3.0