pyngspice is a Python binding for the circuit simulator Ngspice, enabling seamless integration of Ngspice simulations within Python scripts. This project draws significant inspiration from PySpice but aims for faster performance by leveraging Python’s C extension capabilities.
Before installing, you need to set up Ngspice on your system.
- Download the latest Ngspice DLL package from this link.
- Extract the downloaded file and rename the
Spice64_dll
folder toSpice64
. - Move the
Spice64
folder to theC:\\
directory.
For Debian-based distributions (e.g., Ubuntu):
sudo apt install libngspice0-dev ngspice
For Fedora-based distributions:
sudo dnf install libngspice-devel ngspice-codemodel
(Note: The Fedora-based installation has not yet been tested.)
For macOS users, Ngspice can be installed using Homebrew:
brew install ngspice
For those requiring multithreading support of Ngspice, you can install the OpenMP version using the following script (supported on Linux and macOS):
curl -sSL https://raw.githubusercontent.com/LeunPark/pyngspice/main/scripts/install-ngspice-omp.sh | bash -
Once Ngspice is installed, you can proceed to install pyngspice
:
pip install git+https://github.com/LeunPark/pyngspice.git
If you encounter errors related to pkg-config
during installation, you may need to install it separately.
import pyngspice