Python-for-Spice (py4spice)
Lightweight Python package interface to Ngspice
Motivation
Ngspice is an open source electrical circuit simulator. It typically executes in batch mode using an archaic script interface. The Python-for-Spice package facilitates Ngspice execution using Python scripts. You can launch multiple analyses and convert the results to NumPy arrays, enabling downstream computation or plotting with Matplotlib.
A modest knowledge of Ngspice and Python is required.
Installation
Install Ngspice
Ngspice must be installed. For most Linux distributions, ngspice can be installed with a package manager. As an example, for Debian use the following commands:
sudo apt update
sudo apt install ngspice
ngspice -v
Install py4spice
py4spice is installed in the customary way for a PyPI package.
sudo apt update
sudo apt install py4spice
Package Modules
| Module | Description |
|---|---|
analyses |
Prepares analysis command that will go into control file and be executed during simulation |
control |
Generate control file to for a simulation |
kicad_netlist |
Create and execute a Kicad netlist export from a schematic |
netlist |
Create, modify, and combine netlists to prepare for an Ngspice simulation |
plot |
Matplotlib plot of numpy results from simulation |
print_section |
Section off text so it is easier to read in terminal |
sim_results |
Create objects for results extracted from simulation text files. Depending on the analysis type, the data are stored in different ways: either a plot or a table (dictionary) |
simulate |
Setup or run an Ngspice simulation |
step_info |
Perform variable measurements from step analyses. (i.e. rise-time, frequency, ...) |
vectors |
Vector set of signals for which to gather data, plot, ... |
waveforms |
Waveforms with a single x value and one or more y values in a 2D numpy array. Header defines the column names |
Release files for py4spice 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py4spice-0.1.0.tar.gz | 13.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py4spice-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.5 kB
Release files / py4spice-0.1.0.tar.gz
| Download URL | py4spice-0.1.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76bac0459c9fee5a5dacfd960f12c6f33d656cab54afd562ba2f0ce2040bb992
|
|
BLAKE2b-256 checksum How to use checksums |
14b1a720aa6ea48cdee65ca0957797db13c171056d95532cad9e3983c4903f88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2025.
Transparency logRelease files / py4spice-0.1.0-py3-none-any.whl
| Download URL | py4spice-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc88a6eb456b27b3bb7758b6176b8d3fd1fb92fd0b606dcc420eb8c0d72f50d4
|
|
BLAKE2b-256 checksum How to use checksums |
2f9f46ca16240006dd0fb790f493b7b0711b1ec73de0277f543ca2b3a7b2127d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2025.
Transparency log