PySpice-org / PySpice

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

OSError: cannot load library '/usr/local/lib/libngspice.dylib' #174

Closed NatarajPinakapani closed 5 years ago

NatarajPinakapani commented 5 years ago

Environment (Mac Catalina, Python version 3.7.4, PySpice version 1.3.2, ngspice version 31)

Expected Behaviour

The following code should execute without any error

!/usr/local/bin/ python3

r# This example shows the computation of the DC bias and sensitivity in a voltage divider.

# #################################################################################################### import PySpice.Logging.Logging as Logging logger = Logging.setup_logging() from PySpice.Spice.Netlist import Circuit, SubCircuit, SubCircuitFactory from PySpice.Unit import * ####################################################################################################

class VoltDiv(SubCircuitFactory): name='VoltDiv' nodes=('in1', 'out', 'gnd') def init(self, R1_r, R2_r): super().init() self.R(1, 'in1', 'out', R1_r) self.R(2, 'out', 'gnd', R2_r)

End def init

End Class VoltDiv

Start Test Bench

circuit=Circuit('vd') circuit.X('1', 'VoltDiv', 'in1', 'out', circuit.gnd ) circuit.V('input', 'in1', circuit.gnd,10) circuit.subcircuit(VoltDiv(10@u_Ohm, 20@u_Ohm))

End Test Bench

def Simulate(dut):

Start Simulation

simulator = dut.simulator(temperature=25, nominal_temperature=25)
##End Simulation 

##Start Output Analysis
analysis=simulator.operating_point()
vout=round(float(analysis.out),2)
for node in analysis.branches.values():
   itot =round(float(node)*-1,2)
print(vout, itot)
return(vout,itot)

Simulate(circuit)

Actual Behaviour

OSError: cannot load library '/usr/local/lib/libngspice.dylib': dlopen(/usr/local/lib/libngspice.dylib, 2): Symbol not found: _omp_set_num_threads Referenced from: /usr/local/lib/libngspice.dylib Expected in: flat namespace in /usr/local/lib/libngspice.dylib

Steps to reproduce the behaviour

python3 The above command reproduces the stated "Actual Behaviour"

BadeSummer commented 4 years ago

I meet the same problem as you. I can find directly the file "libngspice.dylib" is in /usr/local/lib. But as running the PySpice example still occur OSError like yours. Have you solved this problem?

andrecavalcante commented 5 months ago

I have the same problem.