PySpice-org / PySpice

Simulate electronic circuit using Python and the Ngspice / Xyce simulators
https://pyspice.fabrice-salvaire.fr
GNU General Public License v3.0
652 stars 171 forks source link

Ubuntu 18.04 Missing libngspice.so steps to install #234

Open davehaglan opened 4 years ago

davehaglan commented 4 years ago

Environment (Ubuntu 18.04, Python 3.6, PySpice 1.4.2, ngspice)

Ubuntu Issue

Running ngspice gives the error: OSError: cannot load library 'libngspice.so': libngspice.so: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libngspice.so'

Steps to Fix it

Several people seem to have trouble running pypice/ngspice on Ubuntu 18.04. I was able to generate the libngspice.so files following the procedure below.

Install ngspice32 following the instructions in section 32.1.5 of the documentation.

Once the install is complete link the libngspice.so files to the unix library. cd /usr/lib/x86_64-linux-gnu sudo ln -s /usr/local/lib/libngspice.so.0.0.0 libngspice.so sudo ln -s /usr/local/lib/libngspice.so.0.0.0 libngspice.so.0 sudo ln -s /usr/local/lib/libngspice.so.0.0.0 libngspice.so.0.0.0

Install pyspice from git (PIP install was unable to run the pyspice-post-installation --check-install) git clone https://github.com/FabriceSalvaire/PySpice.git

After this I was able to run the RC example.

Forum post that led to the solution above: https://forum.kicad.info/t/ngspice-30-simulator-available/14426/2

FabriceSalvaire commented 4 years ago

These instructions (section 32.1.5) are probably incomplete.

Did you look at https://pyspice.fabrice-salvaire.fr/releases/v1.4/installation.html#ngspice-installation ? You should be able to install

Ubuntu: libngspice0 https://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=libngspice&searchon=names

davehaglan commented 4 years ago

I was not able to install the libngspice.so packages from the Ubuntu page. The Ubuntu packages are for Ubuntu versions newer than 18.04.

I had installed ngspice using "apt-get install ngspice" but it did not install the libngspice.so and I was not able to run any examples due to the missing libngspice.so. After, I followed the steps above I was able to run the examples successfully. I posted my method to install the libngspice.so since it seemed like a couple of Ubuntu 18.04 users had the same problem.

Still learning the ngspice package but I like what I see so far. Thanks!

FabriceSalvaire commented 4 years ago

@davehaglan I cannot reproduce this issue, these links should have been created by make install