PySpice
Simulate electronic circuit using Python and the Ngspice / Xyce simulators
What it is and what it does
PySpice is a Python module that bridges your code to the Ngspice and Xyce circuit simulators, letting you define electronic circuits using an object-oriented API instead of writing SPICE netlists by hand. It handles unit conversions, exports simulation results to NumPy arrays, and integrates with Matplotlib for plotting. The package includes a partial SPICE netlist parser, support for KiCad schematic integration, and bindings to Ngspice's shared library via CFFI.
You use PySpice when you want to automate circuit simulation, sweep parameters programmatically, or integrate circuit analysis into a larger Python workflow. It's aimed at engineers and students who prefer scripting over GUI-based simulators. The main dependencies are scientific libraries (NumPy, SciPy, Matplotlib) plus PyYAML and PLY for parsing.
Use it for:
- Automate parametric sweeps and optimization loops for circuit designs without manual netlist editing.
- Generate circuit netlists from KiCad schematics and run simulations directly from Python.
- Integrate circuit simulation into a data analysis or machine-learning pipeline using NumPy and SciPy.
- Teach circuit analysis and simulation in an educational setting with interactive Python notebooks.
- Parse and programmatically modify existing SPICE netlists for batch processing or design exploration.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PySpice provides a Python interface to Ngspice and Xyce circuit simulators, allowing you to define, simulate, and analyze electronic circuits programmatically with support for netlist parsing, unit handling, and visualization.
Yes, if you need to automate SPICE simulation in Python and can install Ngspice or Xyce separately. The package is stable and production-ready, but maintenance is dormant (last release 2021); it remains suitable for established workflows but may not receive fixes for new simulator versions or Python features. No known security vulnerabilities. GPLv3 copyleft applies—verify compatibility with your project's licensing.
Install
pyspice on PyPI
pip
pip install pyspiceuv
uv add pyspicepoetry
poetry add pyspiceInstalling PySpice
Before you install
Low friction install with a pure-Python wheel. Maintenance is dormant—last release was in 2021 and no commits since August 2024—but the package remains stable and archived repository is not flagged as abandoned.
License in practice
Licensed under GPLv3 (copyleft). Any derivative work or modification must also be released under GPLv3; proprietary or closed-source projects cannot incorporate this package without releasing their own source code.
Quickstart
pip install PySpice
from PySpice.Spice.Netlist import Circuit
from PySpice.Unit import *
circuit = Circuit('Simple RC')
circuit.V('input', 1, circuit.gnd, 1@u_V)
circuit.R(1, 1, 2, 1@u_kΩ)
circuit.C(1, 2, circuit.gnd, 1@u_uF)
Requires Ngspice or Xyce simulator installed separately on your system; PySpice is a Python binding only and does not bundle the simulator itself.
Verify before relying
- Whether Ngspice/Xyce installation is straightforward on all supported platforms (Windows, Linux, macOS).
- Current compatibility with modern Ngspice/Xyce versions beyond those tested in 2021.
- Whether the dormant maintenance status affects real-world usability for new circuit designs.
Package facts
| License | GPLv3 (copyleft) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — PyYAML, cffi, matplotlib, numpy, ply, scipy, requests |
| Maintenance | dormant — 1,917 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 125,460/month — #11,817 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: PySpice-1.5-py2.py3-none-any.whl
Keywords: ngspice, xyce, spice, berkeley, electronic, circuit, simulation, simulator
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
gpluginsGplugins provides a plugin system for…
unclear · top 15,000 on PyPI
kfactoryKFactory is a Python framework for designing…
unclear · top 15,000 on PyPI
spiceypySpiceyPy wraps the NAIF C SPICE Toolkit to…
permissive · top 15,000 on PyPI
FMPyFMPy simulates Functional Mock-up Units (FMUs)…
unclear · top 15,000 on PyPI
gdsfactoryGDSFactory generates CAD files (GDS, OASIS,…
unclear · top 15,000 on PyPI
saxSAX is a JAX-based simulator and optimizer for…
permissive · top 15,000 on PyPI
PyVISA-simPyVISA-sim provides a simulated VISA backend…
permissive · top 15,000 on PyPI
pyaedtPyAEDT provides a Python API to script and…
permissive · top 15,000 on PyPI
stimStim is a fast simulator for quantum stabilizer…
permissive · top 15,000 on PyPI
resfo-utilitiesresfo-utilities parses and processes output…
copyleft · top 15,000 on PyPI