Getting keyerror while running example

As i’m new to pyspice when i am running this example

I am getting this keyerror

I m using windows 10 64 bit
Ide : Anaconda python
Pyspice 1.4.3
Ngspice 32

If any gentlemen has idea how to fix this it ll help me a lot :smiley:

Its a common error. You need to make sure the 1N4148.lib file exists and its path is properly defined.

One way to define and handle diode models is here: Introduction to PYSPICE (Python) for Simulating a complete Regulated Power Supply Circuit - YouTube

1 Like

Thankyou for response sir,
i’ve downloaded 1N4148.lib from the github examples library. As i m new to pyspice can you please tell me how to define path properly ? It ll be really helpful if you explain in detail how to define path properly .I ve watched your amazing tutorials on pyspice so far.

May be a youtube video on this topic may help many begineers who come across this error.
Thankyou sir.

You need to have an understanding of how paths work in python.

A better solution is to just define the diode model within the Python script:

circuit.model(‘1N4148’, ‘D’, IS = 4.352E-9, N = 1.906, BV = 110, IBV = 0.0001, RS = 0.6458, CJO = 7.048E-13, VJ = 0.869, M = 0.03, FC = 0.5, TT = 3.48E-9)

Modify the line in the netlist where the diode is defined to include:

model = ‘1N4148’

1 Like