skillfed

PySpice

Simulate electronic circuit using Python and the Ngspice / Xyce simulators

pyspice v1.5 125.5K downloads/30d#11,817 on PyPI857
Copyleft license GPLv3 DORMANT released

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 pyspice

uv

uv add pyspice

poetry

poetry add pyspice

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: EducationLicense :: OSI Approved :: GNU General Public License (GPL)Operating System :: OS IndependentProgramming Language :: Python :: 3.6Topic :: Scientific/Engineering

Tags

circuit simulation pythonngspice python interfacespice simulator wrapperelectronic circuit analysiscircuit netlist parserspice simulation libraryxyce python binding
circuit-simulationspice-bindingeda-automation

More Scientific/Engineering packages