PySpice
PySpice copied to clipboard
OSError: cannot load library ngspice.dll': error 0x7e
Environment (OS, Python version, PySpice version, simulator)
Win10.0.19041 Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32 PySpice 1.4.3 NgSpice
Expected Behaviour
The ngspice.dll should load without an error.
Actual Behaviour
Traceback (most recent call last):
File "test_pyspice.py", line 16, in
Steps to reproduce the behaviour
I try to run the "Resistor Bridge" example on a fresh installation. I have installed pyspice direct with "pip install pyspice". Afterwards I have run "pyspice-post-installation --install-ngspice-dll". The installation steps have processed without any error. The test "pyspice-post-installation --check-install" gives the same error as shown above.
Do you have any hint how to solve this problem? I want to avoid Anaconda, hence the direct installation with pip. As far as I understand the docs this should also be possible?
Regards HR42
Oh, I found the solution: The NgSpice DLL folder must be on the windows path. Fortunately this can be made within the python script: In my case it is:
import os
os.environ["path"] += os.pathsep + r"C:\Python38\lib\site-packages\PySpice\Spice\NgSpice\Spice64_dll\dll-vs"
With this modification the example works as expected.
A specific hint might be helpful when this particular exception occurs? E.g. "Please ensure that the DLL folder is on the windows PATH." Also a short note in the documentation would be very helpful: https://pyspice.fabrice-salvaire.fr/releases/v1.4/installation.html#on-windows
Regards HR42
For me I solved solved this with followed steps :
- install visual studio code
- create venv
- install al needed python libs in venv (numpy, matplotlib, pyspice(don't know if it is needed))
- change intepreter in visual studio code
- in venv run : pyspice-post-installation --install-ngspice-dll
- in venv run : pyspice-post-installation --check-install -> PySpice should work as expected
For me i solved it with:
run this 2 comands over the Terminal:
-
cd in to --> cd C:\Users\YOUR_PC_NAME\AppData\Roaming\Python\Python39\Scripts
-
run this comand --> .\pyspice-post-installation --install-ngspice-dll