Transistor Example

In the example 8.20.1 AC Coupled Amplifier, when I was trying to run the code in Jupyter Notebook

simulator = circuit.simulator(temperature=25, nominal_temperature=25)

it shows:


OSError Traceback (most recent call last)
in
----> 1 simulator = circuit.simulator(temperature=25, nominal_temperature=25)

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Netlist.py in simulator(self, *args, **kwargs)
1297
1298 def simulator(self, *args, **kwargs):
-> 1299 return CircuitSimulator.factory(self, *args, **kwargs)

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Simulation.py in factory(cls, circuit, *args, **kwargs)
1117
1118 if sub_cls is not None:
-> 1119 return sub_cls(circuit, *args, **kwargs)
1120 else:
1121 raise ValueError(‘Unknown simulator type’)

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Simulation.py in init(self, circuit, **kwargs)
97 ngspice_shared = kwargs.get(‘ngspice_shared’, None)
98 if ngspice_shared is None:
—> 99 self._ngspice_shared = NgSpiceShared.new_instance()
100 else:
101 self._ngspice_shared = ngspice_shared

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in new_instance(cls, ngspice_id, send_data, verbose)
450 else:
451 cls._logger.debug(“New instance for id {}”.format(ngspice_id))
–> 452 instance = cls(ngspice_id=ngspice_id, send_data=send_data, verbose=verbose)
453 cls._instances[ngspice_id] = instance
454 return instance

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in init(self, ngspice_id, send_data, verbose)
478
479 self._library_path = None
–> 480 self._load_library(verbose)
481 self._init_ngspice(send_data)
482

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in _load_library(self, verbose)
538 if verbose:
539 print(message)
–> 540 self._ngspice_shared = ffi.dlopen(self.library_path)
541
542 # Note: cannot yet execute command

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in dlopen(self, name, flags)
148 “or an already-opened ‘void *’ handle”)
149 with self._lock:
–> 150 lib, function_cache = _make_ffi_library(self, name, flags)
151 self._function_caches.append(function_cache)
152 self._libraries.append(lib)

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in _make_ffi_library(ffi, libname, flags)
830 def _make_ffi_library(ffi, libname, flags):
831 backend = ffi._backend
–> 832 backendlib = _load_backend_lib(backend, libname, flags)
833 #
834 def accessor_function(name):

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in _load_backend_lib(backend, name, flags)
825 if first_error is not None:
826 msg = “%s. Additionally, %s” % (first_error, msg)
–> 827 raise OSError(msg)
828 return backend.load_library(path, flags)
829

OSError: cannot load library ‘libngspice.dylib’: dlopen(libngspice.dylib, 2): image not found. Additionally, ctypes.util.find_library() did not manage to locate a library called ‘libngspice.dylib’