Skip to content

virtualenv problem? - nope identified - jupyter notebook issue #175

@ag-123

Description

@ag-123

in linux opensuse leap15.1, i did a virtualenv myPySpice
then myPySpice/bin/activate - this gets into the virtual environment setup for myPySpice
next i installed PySpice using pip3 install PySpice
i setup a jupyter-notebook with the correct myPySpice virtual env for both cases below
among the examples i tried:
this one seem to work just ok no errors
https://pyspice.fabrice-salvaire.fr/examples/basic-usages/subcircuit.html
but when i tried this one
https://pyspice.fabrice-salvaire.fr/examples/ngspice-shared/external-source.html
at the codes:

circuit = Circuit('Voltage Divider')

circuit.V('input', 'input', circuit.gnd, 'dc 0 external')
circuit.R(1, 'input', 'output', 10@u_kΩ)
circuit.R(2, 'output', circuit.gnd, 1@u_kΩ)

amplitude = 10@u_V
frequency = 50@u_Hz
ngspice_shared = MyNgSpiceShared(amplitude=amplitude, frequency=frequency, send_data=False)
simulator = circuit.simulator(temperature=25, nominal_temperature=25,
                              simulator='ngspice-shared', ngspice_shared=ngspice_shared)
period = float(frequency.period)
analysis = simulator.transient(step_time=period/200, end_time=period*2)

i got an error as such:

CDefError                                 Traceback (most recent call last)
<ipython-input-5-a9a533de9403> in <module>
      7 amplitude = 10@u_V
      8 frequency = 50@u_Hz
----> 9 ngspice_shared = MyNgSpiceShared(amplitude=amplitude, frequency=frequency, send_data=False)
     10 simulator = circuit.simulator(temperature=25, nominal_temperature=25,
     11                               simulator='ngspice-shared', ngspice_shared=ngspice_shared)

<ipython-input-2-c99757b71241> in __init__(self, amplitude, frequency, **kwargs)
      4     def __init__(self, amplitude, frequency, **kwargs):
      5 
----> 6         super().__init__(**kwargs)
      7 
      8         self._amplitude = amplitude

~/python/venv/pyspice/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in __init__(self, ngspice_id, send_data)
    347         self._stderr = []
    348 
--> 349         self._load_library()
    350         self._init_ngspice(send_data)
    351 

~/python/venv/pyspice/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in _load_library(self)
    365         api_path = os.path.join(os.path.dirname(__file__), 'api.h')
    366         with open(api_path) as f:
--> 367             ffi.cdef(f.read())
    368 
    369         if not self._ngspice_id:

~/python/venv/pyspice/lib/python3.6/site-packages/cffi/api.py in cdef(self, csource, override, packed, pack)
    110         packed=True).
    111         """
--> 112         self._cdef(csource, override=override, packed=packed, pack=pack)
    113 
    114     def embedding_api(self, csource, packed=False, pack=None):

~/python/venv/pyspice/lib/python3.6/site-packages/cffi/api.py in _cdef(self, csource, override, **options)
    124         with self._lock:
    125             self._cdef_version = object()
--> 126             self._parser.parse(csource, override=override, **options)
    127             self._cdefsources.append(csource)
    128             if override:

~/python/venv/pyspice/lib/python3.6/site-packages/cffi/cparser.py in parse(self, csource, override, packed, pack, dllexport)
    349                              'packed': pack,
    350                              'dllexport': dllexport}
--> 351             self._internal_parse(csource)
    352         finally:
    353             self._options = prev_options

~/python/venv/pyspice/lib/python3.6/site-packages/cffi/cparser.py in _internal_parse(self, csource)
    389                     else:
    390                         realtype, quals = self._get_type_and_quals(
--> 391                             decl.type, name=decl.name, partial_length_ok=True)
    392                     self._declare('typedef ' + decl.name, realtype, quals=quals)
    393                 elif decl.__class__.__name__ == 'Pragma':

~/python/venv/pyspice/lib/python3.6/site-packages/cffi/cparser.py in _get_type_and_quals(self, typenode, name, partial_length_ok)
    621             if isinstance(type, pycparser.c_ast.Struct):
    622                 # 'struct foobar'
--> 623                 tp = self._get_struct_union_enum_type('struct', type, name)
    624                 return tp, quals
    625             #

~/python/venv/pyspice/lib/python3.6/site-packages/cffi/cparser.py in _get_struct_union_enum_type(self, kind, type, name, nested)
    768         #
    769         if tp.fldnames is not None:
--> 770             raise CDefError("duplicate declaration of struct %s" % name)
    771         fldnames = []
    772         fldtypes = []

CDefError: <cdef source string>:7: duplicate declaration of struct ngcomplex

I've been trying to figure out what may be wrong, but strangely it successfully plots the graph that is shown in the example
external source plot

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions