如何修复 pyspice OSError: cannot load library 'libngspice.so'
问题:
尝试运行 PySpice 程序时,你会看到类似这样的错误消息
pyspice_libngspice_error.txt
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'解决方案
安装 libngspice,通常称为 libngspice0。
在 Ubuntu 上,使用以下命令安装
install_libngspice0_dev.sh
sudo apt -y install libngspice0-dev你需要安装 -dev 库,因为 libngspice0 只包含 libngspice.so.0,而 -dev 库包含 pyspice 所需的 libngspice.so。
解决方案(Linux 上已安装 KiCad)
KiCad 自动安装 libngspice-kicad,它提供 libngspice.so.0 但与 libngspice0 和 libngspice0-dev 冲突。要解决此问题,你可以创建一个符号链接:
symlink_libngspice.sh
sudo ln -sf /usr/lib/x86_64-linux-gnu/libngspice.so.0 /usr/lib/x86_64-linux-gnu/libngspice.so之后,重启你的 Python 脚本,现在应该可以工作了。
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow