4. Installation

Note to Packagers: Please don’t create PySpice package (PiPY do the job)

4.1. On Windows

Firstly, you have to install Ngspice for Windows from this page. Download the archive ngspice-30_dll_64.zip from thex release page and unzip the files in C:\Program Files\Spice64_dll.

Secondly, you have to install the Anaconda Distribution or Miniconda so as to get a full featured Python 3 environment.

Then open the Anaconda Navigator and launch a console for your root environment.

You can now run pip to install PySpice in your root environment using this command:

pip install PySpice

4.2. On Linux

Firstly, you have to install Python 3 from your distribution.

The Ngspice shared library is actually not available on several distributions including Fedora and Ubuntu. I encourage you to report this issue on your distribution.

On Fedora, I recommend to don’t install the Fedora’s ngspice package since it is badly compiled and maintained. To install the Ngspice shared library, you can use my Ngspice Copr repository:

dnf copr enable fabricesalvaire/ngspice
dnf install libngspice

The RPM sources are available on Pagure.io

If you are not able to install the Ngspice shared library easily on your system, but you can install the Ngspice program, then you can use the “subprocess” mode in replacement of the “shared” mode. In this case, you have to set globally the default simulator using the attribute PySpice.Spice.Simulation.CircuitSimulator.DEFAULT_SIMULATOR to ngspice-subprocess.

Then you can install PySpice using pip or from source. See supra.

4.3. On OSX

There are several ways to get Python on OSX:

The Ngspice shared library is available from Brew:

brew install libngspice

You can install PySpice using pip or from source. See supra.

4.4. How to get the Examples

Examples are not installed by pip or setup.pip. The installation process only install PySpice on your Python environment.

You have to download the PySpice archive or clone the Git repository to get the examples. See “Installation from Source”.

Note: We could install examples with pip, but files would be more difficult to locate in the environment directory.

4.5. Installation from PyPi Repository

PySpice is available on the Python Packages PyPI repository at https://pypi.python.org/pypi/PySpice

Run this command in the console to install the latest release:

pip install PySpice

4.6. Install a more recent version from Github

If you want to install a version which is not yet released on Pypi, you can use one of theses commands to install the stable or devel branch:

pip install git+https://github.com/FabriceSalvaire/PySpice

pip install git+https://github.com/FabriceSalvaire/PySpice@devel

4.7. Installation from Source

The PySpice source code is hosted at https://github.com/FabriceSalvaire/PySpice

You have two solution to get the source code, the first one is to clone the repository, but if you are not familiar with Git then you can simply download an archive either from the PySpice Pypi page (at the bottom) or the GitHub page (see clone or download button).

To clone the Git repository, run this command in a console:

git clone https://github.com/FabriceSalvaire/PySpice.git

Then to build and install PySpice run these commands:

python setup.py build
python setup.py install

4.8. Dependencies

PySpice requires the following dependencies:

Also it is recommanded to have these Python modules:

To generate the documentation, you will need in addition:

  • Sphinx
  • circuit_macros and a LaTeX environment

4.9. Ngspice Compilation

Usually Ngspice is available as a package on the most popular Linux distributions. But I recommend to check the compilation options before to use it extensively. For example the Fedora package enables too many experimental codes that have side effects. The recommended way to compile Ngspice is given in the manual and in the INSTALLATION file. Ngspice is an example of complex software where we should not enable everything without care.

Warning

Compilation option –enable-ndev is known to broke the server mode.

The recommended way to compile Ngspice on Fedora is:

mkdir ngspice-27-build
pushd ngspice-27-build

/.../ngspice-27/configure \
  --prefix=/usr/local \
  --enable-xspice \
  --disable-debug \
  --enable-cider \
  --with-readline=yes \
  --enable-openmp \
  --with-ngshared

 make # -j4
 make install

4.10. How to get Xyce ?

Despite Xyce is released under the therms of the GPLv3 licence, Sandia requires actually you create a user account on this sign-in page so as to get the source or download an executable, i.e. you have to provide your email address to Sandia.

The building procedure is clearly explained in the building guide.

You can also find the sources for a Xyce RPM package in this Git repository.