object has no attribute

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
selters
User
Beiträge: 4
Registriert: Dienstag 28. Juni 2022, 15:19

Hallo,
ich versuche gerade für meine Bachelorarbeit eine Schnittstelle zwischen Python und Solidworks zu programmieren. Ich habe bereits einen Wrapper (pySW) dafür gefunden, aber wird leider bei einer Stelle immer die folgende Fehlermeldung gezeigt: 'commSW' object has no attribute 'getGlobalVariables' obwohl die Funktion 'getGlobalVariables' in commSW existiert.

pySW: https://github.com/kalyanpi4/pySW

Code: Alles auswählen

import os
from pySW import SW
from pyDOE import *
import psutil, time, shutil

partName =  '\Box.SLDPRT' # Name of the part 
thisDir = os.getcwd() # Python method getcwd() returns current working directory of a process.
directory = thisDir + partName # Directory of the part
print(directory) #test to indicate the file location (thisDir)
os.startfile("C:/Program Files/SOLIDWORKS Corp/SOLIDWORKS/SLDWORKS.exe") # os.startfile() opens any program, text or office document
time.sleep(15) # The sleep() function suspends (waits) execution of the current thread for a given number of seconds."""
SW.connectToSW() # Function to establish a connection to Solidworks from Python
#SW.openPrt(directory) # Function to open an part document in Solidworks from Python.
globVars = SW.getGlobalVars() # Gives a dictionary of the global variables
variables = []; # An empty list for the lobal variable names
for key in globVars:
    variables.append(key); # Adds the names imported from SW global viariables list
print(globVars)
print(variables)
newValues = [70, 120, 45]
unitList = ['mm']*len(variables)
print(unitList)

SW.modifyGlobalVar(variables, newValues, unitList)
Hier ist ein Link zur Klasse commSW: https://github.com/kalyanpi4/pySW/blob/ ... commSW.py

Weiß jemand wie ich diesen Fehler beheben kann? Danke im Voraus.
Benutzeravatar
__blackjack__
User
Beiträge: 13006
Registriert: Samstag 2. Juni 2018, 10:21
Wohnort: 127.0.0.1
Kontaktdaten:

@selters: Bei Fehlermeldungen/Ausnahmen bitte immer den gesamten Traceback 1:1 zeigen, damit man sehen kann wo die Ausnahme genau auftritt, sowohl in Deinem Code, als auch in der Bibliothek in der die Ausnahme ausgelöst wird.

Anmerkungen zum Quelltext:

Kommentare sollten dem Leser einen Mehrwert über den Code bieten. Im Kommentar noch mal zu schreiben was dort schon als Code steht, tut das nicht. Faustregel: Kommentare beschreiben nicht was der Code macht, sondern warum er das so macht, sofern das nicht offensichtlich ist. Was in der Dokumentation von Python und den verwendeten Bibliotheken steht ist in der Regel offensichtlich.

So etwas wie ``partName = …`` mit ``# Name of the part.`` zu kommentieren bringt dem Leser genau 0 Erkenntnisgewinn.

`shutil` und `psutil` werden importiert aber nicht verwendet.

Sternchen-Importe sind Böse™. Es besteht die Gefahr von Namenskollisionen, und man sieht auch nicht mehr so leicht wo eigentlich welcher Name her kommt.

Namen werden in Python klein_mit_unterstrichen geschrieben. Ausnahmen sind Konstanten (KOMPLETT_GROSS) und Klassennamen (PascalCase).

Namen sollten keine kryptischen Abkürzungen enthalten, oder gar nur daraus bestehen. Wenn man `global` meint, sollte man nicht `glob` schreiben. Zumal dieses Wort im Zusammenhang mit Dateinamen eine Bedeutung hat. Man muss also nicht nur überlegen was die Abkürzung bedeutet, man kann auch leicht falsch raten.

`os.getcwd()` ist hier überflüssig. Ob man das nun vor einen Dateinamen hängt oder nicht, ändert letztlich ja nichts.

Man setzt auch Pfadteile nicht einfach mit ``+`` zusammen. Dafür gibt es das `pathlib`-Modul. Wenn man das aktuelle Arbeitsverzeichnis braucht, würde man sich auch das mit dem `pathlib`-Modul holen und nicht mehr mit `os.getcwd()`.

Semikolon am Zeilenende ist überflüssig. Das ist in Python ein Trenner und kein Abschluss wie in anderen Programmiersprachen. Und da man in der Regel eine Anweisung pro Zeile schreibt, sieht man das so gut wie nie in Python-Quelltexten.

Statt eine Liste zu erstellen und dann in einer Schleife alle Werte aus etwas iterierbaren anzuhängen, hätte man einfach `list()` aufrufen können.

`variables` für eine Liste ist ein etwas irreführender Name wenn es `global_variables` als Wörterbuch gibt. Ein passenderer Name für die Liste wäre `variable_names` oder nur `names` wenn es nichts ähnliches gibt, mit dem man das verwechseln könnte.

Überarbeitet (ungetestet):

Code: Alles auswählen

#!/usr/bin/env python3
import os
import time

from pySW import SW


def main():
    part_name = "Box.SLDPRT"
    os.startfile("C:/Program Files/SOLIDWORKS Corp/SOLIDWORKS/SLDWORKS.exe")
    time.sleep(15)

    SW.connectToSW()
    # SW.openPrt(part_name)
    global_variables = SW.getGlobalVars()
    print(global_variables)

    SW.modifyGlobalVar(
        list(global_variables), [70, 120, 45], ["mm"] * len(global_variables)
    )


if __name__ == "__main__":
    main()
Wobei ich mal vermute man sollte prüfen, dass die Anzahl der Elemente in `global_variables` 3 ist. Und in der erwarteten Reihenfolge vielleicht auch.
“Most people find the concept of programming obvious, but the doing impossible.” — Alan J. Perlis
narpfel
User
Beiträge: 643
Registriert: Freitag 20. Oktober 2017, 16:10

In deinem Code kommt kein `getGlobalVariables` vor? Bitte zeige genau den Code, den du ausführst (nicht irgendwas ähnliches) und genau den vollständigen Traceback, der angezeigt wird. Beides per Copy-Paste, nicht abtippen. Sonst kann man nicht effizient helfen und muss raten, ob der Unterschied zwischen Erwartung, Code und Exception nur ein Fehler in der Fragestellung ist oder tatsächlich das Problem.
selters
User
Beiträge: 4
Registriert: Dienstag 28. Juni 2022, 15:19

Herzlichen Dank __blackjack__ für die sehr hilfreiche Tips. Ich werde es nochmal später mit pathlib probieren, da es mit

Code: Alles auswählen

from pathlib import Path

part_path = Path(Path.home(), "Downloads","Box.SLDPRT")
nicht geklappt hat.

Hier sind nun der bearbeitete Code und der Traceback:

Code: Alles auswählen

import os
from pySW import SW


part_path = os.getcwd() + "\Box.SLDPRT"
SW.connectToSW()                           # Function to establish a connection to Solidworks from Python
SW.openPrt(part_path)
global_variables = SW.getGlobalVars()
SW.modifyGlobalVar(
        list(global_variables), [70, 120, 45], ["mm"] * len(global_variables)
    )
Traceback:

Code: Alles auswählen

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-4444e491c404> in <module>
      7 SW.openPrt(part_path)
      8 global_variables = SW.getGlobalVars()
----> 9 SW.modifyGlobalVar(
     10         list(global_variables), [70, 120, 45], ["mm"] * len(global_variables)
     11     )

~\anaconda3\lib\site-packages\pySW\commSW.py in modifyGlobalVar(self, variable, modifiedVal, unit)
    120         eqMgr   = model.GetEquationMgr;
    121         #
--> 122         data    = self.getGlobalVariables();
    123         #
    124         if isinstance(variable, str) == True:

AttributeError: 'commSW' object has no attribute 'getGlobalVariables'
Class commSW:

Code: Alles auswählen

"""
# *****************************************************************************
# *                                                                           *
# *    Copyright (C) 2020  Kalyan Inamdar, kalyaninamdar@protonmail.com       *
# *                                                                           *
# *    This library is free software; you can redistribute it and/or          *
# *    modify it under the terms of the GNU Lesser General Public             *
# *    License as published by the Free Software Foundation; either           *
# *    version 2 of the License, or (at your option) any later version        *
# *                                                                           *
# *    This library is distributed in the hope that it will be useful,        *
# *    but WITHOUT ANY WARRANTY; without even the implied warranty of         *
# *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
# *    GNU Lesser General Public License for more details.                    *
# *                                                                           *
# *    You should have received a copy of the GNU General Public License      *
# *    along with this program.  If not, see http://www.gnu.org/licenses/.    *
# *                                                                           *
# *****************************************************************************
"""
import subprocess as sb
import win32com.client
import pythoncom
import os
#
class commSW:
    def __init__(self):
        pass;
    #
    def startSW(self, *args):
        #                                                                     #
        # Function to start Solidworks from Python.                           #
        #                                                                     #
        # Accepts an optional argument: the year of version of Solidworks.    #
        #                                                                     #
        # If you have only one version of Solidworks on your computer, you do #
        # not need to provide this input.                                     #
        #                                                                     #
        # Example: If you have Solidworks 2019 and Solidworks 2020 on your    #
        # system and you want to start Solidworks 2020 the function you call  #
        # should look like this: startSW(2020)                                #
        #                                                                     #
        if not args:
            SW_PROCESS_NAME = r'C:/Program Files/SOLIDWORKS Corp/SOLIDWORKS/SLDWORKS.exe';
            sb.Popen(SW_PROCESS_NAME);
        else:
            year= int(args[0][-1]);
            SW_PROCESS_NAME = "SldWorks.Application.%d" % (20+(year-2));
            win32com.client.Dispatch(SW_PROCESS_NAME);
    #
    def shutSW(self):
        #                                                                     #
        # Function to close Solidworks from Python.                           #
        # Does not accept any input.                                          #
        #                                                                     #
        sb.call('Taskkill /IM SLDWORKS.exe /F');
    #
    def connectToSW(self):
        #                                                                     #
        # Function to establish a connection to Solidworks from Python.       #
        # Does not accept any input.                                          #
        #                                                                     #
        global swcom
        swcom = win32com.client.Dispatch("SLDWORKS.Application");
    #
    def openAssy(self, prtNameInp):
        #                                                                     #
        # Function to open an assembly document in Solidworks from Python.    #
        #                                                                     #
        # Accepts one input as the filename with the path if the working      #
        # directory of your script and the directory in which the assembly    #
        # file is saved are different.                                        #
        #                                                                     #
        self.prtNameInn = prtNameInp;
        self.prtNameInn = self.prtNameInn.replace('\\','/');
        #
        if os.path.basename(self.prtNameInn).split('.')[-1].lower() == 'sldasm': 
            pass;
        else:
            self.prtNameInn+'.SLDASM'
        #
        openDoc     = swcom.OpenDoc6;
        arg1        = win32com.client.VARIANT(pythoncom.VT_BSTR, self.prtNameInn);
        arg2        = win32com.client.VARIANT(pythoncom.VT_I4, 2);
        arg3        = win32com.client.VARIANT(pythoncom.VT_I4, 0);
        arg5        = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_I4, 2);
        arg6        = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_I4, 128);
        #
        openDoc(arg1, arg2, arg3, "", arg5, arg6);
    #
    def openPrt(self, prtNameInp):
        #                                                                     #
        # Function to open an part document in Solidworks from Python.        #
        #                                                                     #
        # Accepts one input as the filename with the path if the working      #
        # directory of your script and the directory in which the part file   #
        # is saved are different.                                             #
        #                                                                     #
        self.prtNameInn = prtNameInp;
        self.prtNameInn = self.prtNameInn.replace('\\','/');
        #
        openDoc     = swcom.OpenDoc6;
        arg1        = win32com.client.VARIANT(pythoncom.VT_BSTR, self.prtNameInn);
        arg2        = win32com.client.VARIANT(pythoncom.VT_I4, 1);
        arg3        = win32com.client.VARIANT(pythoncom.VT_I4, 1);
        arg5        = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_I4, 2);
        arg6        = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_I4, 128);
        #
        openDoc(arg1, arg2, arg3, "", arg5, arg6);
    #
    def updatePrt(self):
        if 'model' in globals():
            pass;
        else:
            global model;
            model   = swcom.ActiveDoc;
        model.EditRebuild3;
    #
    def closePrt(self):
        swcom.CloseDoc(os.path.basename(self.prtName));
    #
    def saveAssy(self, directory, fileName, fileExtension):
        if 'model' in globals():
            pass;
        else:
            global model;
            model   = swcom.ActiveDoc;
        directory   = directory.replace('\\','/');
        comFileName = directory+'/'+fileName+'.'+fileExtension;
        arg         = win32com.client.VARIANT(pythoncom.VT_BSTR, comFileName);
        model.SaveAs3(arg, 0, 0);
    #
    def getGlobalVariables(self):
        #                                                                     #
        # Function to extract a set of global variables in a Solidworks       #
        # part/assembly file. The part/assembly is then automatically updated.#
        #                                                                     #
        # Does not accept any input.                                          #
        # Provides output in the form of a dictionary with Global Variables as#
        # the keys and values of the variables as values in the dictionary.   #
        #                                                                     #
        if 'model' in globals():
            pass;
        else:
            global model;
            model   = swcom.ActiveDoc;
        #
        if 'eqMgr' in globals():
            pass;
        else:
            global eqMgr;
            eqMgr = model.GetEquationMgr;
        #
        n = eqMgr.getCount;
        #
        data = {};
        #
        for i in range(n):
            if eqMgr.GlobalVariable(i) == True:
                data[eqMgr.Equation(i).split('"')[1]] = i
            #
        #
        if len(data.keys()) == 0:
            raise KeyError("There are not any 'Global Variables' present in the currently active Solidworks document.");
        else:
            return data;
    #
    def modifyGlobalVar(self, variable, modifiedVal, unit):
        #                                                                     #
        # Function to modify a global variable or a set of global variables   #
        # in a Solidworks part/assembly file. The part/assembly is then       #
        # automatically updated.                                              #
        #                                                                     #
        # Accepts three inputs: variable name, modified value, and the unit   #
        # of the variable. The inputs can be string, integer and string       #
        # respectively or a list of variables, list of modified values and a  #
        # list of units of respective variables.                              #
        #                                                                     #
        # Note: In case you need to modify multiple dimensions using lists    #
        # the length of the lists must strictly be equal.                     #
        #                                                                     #
        if 'model' in globals():
            pass;
        else:
            global model;
            model   = swcom.ActiveDoc;
        #
        if 'eqMgr' in globals():
            pass;
        else:
            global eqMgr;
            eqMgr = model.GetEquationMgr;
        #
        data = self.getGlobalVariables();
        #
        if isinstance(variable, str) == True:
            eqMgr.Equation(data[variable], "\""+variable+"\" = "+str(modifiedVal)+unit+"");
        elif isinstance(variable, list) == True:
            if isinstance(modifiedVal, list) == True:
                if isinstance(unit, list) == True:
                    for i in range(len(variable)):
                        eqMgr.Equation(data[variable[i]], "\""+variable[i]+"\" = "+str(modifiedVal[i])+unit[i]+"");
                else:
                    raise TypeError("If a list of multiple variables is given, then lists of equal \n\
lengths should be given for 'modifiedVal' and 'unit' inputs.");
            else:
                raise TypeError("If a list of multiple variables is given, then lists of equal \n\
lengths should be given for 'modifiedVal' and 'unit' inputs.");
        else:
            raise TypeError("Incorrect input for the variables. Inputs can either be string, integer and string or lists containing variables, values and units.");
        #
        self.updatePrt();
    #
    def modifyLinkedVar(self, variable, modifiedVal, unit, *args):
        #                                                                     #
        # Function to modify a global variable/dimension or a set of          #
        # dimensions in a linked 'equations' file. The part/assembly is then  #
        # automatically updated.                                              #
        #                                                                     #
        # Accepts three inputs: variable name, modified value, and the unit   #
        # of the variable. The inputs can be string, integer and string       #
        # respectively or a list of variables, list of modified values and a  #
        # list of units of respective variables. Additionally the function    #
        # accepts one more optional argument, which is the complete path of   #
        # the equations file. If a path to the equations file is not provided #
        # then the function searches for a file named 'equations.txt' in the  #
        # working directory of the code.                                     #
        #                                                                     #
        # Note: In case you need to modify multiple dimensions using lists    #
        # the length of the lists must strictly be equal.                     #
        #                                                                     #
        #
        # Check the filename
        if len(args) == 0:
            file = 'equations.txt';
        else:
            file = args[0];
        #
        # READ FILE WITH ORIGINAL DIMENSIONS
        try:
            reader      = open(file, 'r');
        except IOError:
            raise IOError;
        finally:
            data = {};
            numLines    = len(reader.readlines());
            reader.close();
            reader      = open(file);
            lines       = reader.readlines();
            reader.close();
            for i in range(numLines):
                dim     = lines[i].split('"')[1];
                tempVal = lines[i].split(' ')[1];
                #
                val     = tempVal.replace(unit,'').replace('= ','').replace('\n','');
                data[dim] = val;
        #
        # MODIFY DIMENSIONS
        if isinstance(variable, list) == True:
            if isinstance(modifiedVal, list) == True:
                if isinstance(unit, list) == True:
                    for z in range(len(variable)):
                        data[variable[i]] = modifiedVal[i];
                else:
                    raise TypeError("If a list of multiple variables is given, then lists of equal \n\
lengths should be given for 'modifiedVal' and 'unit' inputs.");
            else:
                raise TypeError("If a list of multiple variables is given, then lists of equal \n\
lengths should be given for 'modifiedVal' and 'unit' inputs.");
        elif isinstance(variable, str) == True:
            data[variable] = modifiedVal;
        else:
            raise TypeError("The inputs types given.");
        #
        # WRITE FILE WITH MODIFIED DIMENSIONS
        writer      = open(file, 'w');
        for key, value in data.items():
            writer.write('"'+key+'"= '+str(value)+unit);
        writer.close();
        #
        self.updatePrt();
    #
__blackjack__ hat geschrieben: Dienstag 28. Juni 2022, 17:22 @selters: Bei Fehlermeldungen/Ausnahmen bitte immer den gesamten Traceback 1:1 zeigen, damit man sehen kann wo die Ausnahme genau auftritt, sowohl in Deinem Code, als auch in der Bibliothek in der die Ausnahme ausgelöst wird.

Anmerkungen zum Quelltext:

Kommentare sollten dem Leser einen Mehrwert über den Code bieten. Im Kommentar noch mal zu schreiben was dort schon als Code steht, tut das nicht. Faustregel: Kommentare beschreiben nicht was der Code macht, sondern warum er das so macht, sofern das nicht offensichtlich ist. Was in der Dokumentation von Python und den verwendeten Bibliotheken steht ist in der Regel offensichtlich.

So etwas wie ``partName = …`` mit ``# Name of the part.`` zu kommentieren bringt dem Leser genau 0 Erkenntnisgewinn.

`shutil` und `psutil` werden importiert aber nicht verwendet.

Sternchen-Importe sind Böse™. Es besteht die Gefahr von Namenskollisionen, und man sieht auch nicht mehr so leicht wo eigentlich welcher Name her kommt.

Namen werden in Python klein_mit_unterstrichen geschrieben. Ausnahmen sind Konstanten (KOMPLETT_GROSS) und Klassennamen (PascalCase).

Namen sollten keine kryptischen Abkürzungen enthalten, oder gar nur daraus bestehen. Wenn man `global` meint, sollte man nicht `glob` schreiben. Zumal dieses Wort im Zusammenhang mit Dateinamen eine Bedeutung hat. Man muss also nicht nur überlegen was die Abkürzung bedeutet, man kann auch leicht falsch raten.

`os.getcwd()` ist hier überflüssig. Ob man das nun vor einen Dateinamen hängt oder nicht, ändert letztlich ja nichts.

Man setzt auch Pfadteile nicht einfach mit ``+`` zusammen. Dafür gibt es das `pathlib`-Modul. Wenn man das aktuelle Arbeitsverzeichnis braucht, würde man sich auch das mit dem `pathlib`-Modul holen und nicht mehr mit `os.getcwd()`.

Semikolon am Zeilenende ist überflüssig. Das ist in Python ein Trenner und kein Abschluss wie in anderen Programmiersprachen. Und da man in der Regel eine Anweisung pro Zeile schreibt, sieht man das so gut wie nie in Python-Quelltexten.

Statt eine Liste zu erstellen und dann in einer Schleife alle Werte aus etwas iterierbaren anzuhängen, hätte man einfach `list()` aufrufen können.

`variables` für eine Liste ist ein etwas irreführender Name wenn es `global_variables` als Wörterbuch gibt. Ein passenderer Name für die Liste wäre `variable_names` oder nur `names` wenn es nichts ähnliches gibt, mit dem man das verwechseln könnte.

Überarbeitet (ungetestet):

Code: Alles auswählen

#!/usr/bin/env python3
import os
import time

from pySW import SW


def main():
    part_name = "Box.SLDPRT"
    os.startfile("C:/Program Files/SOLIDWORKS Corp/SOLIDWORKS/SLDWORKS.exe")
    time.sleep(15)

    SW.connectToSW()
    # SW.openPrt(part_name)
    global_variables = SW.getGlobalVars()
    print(global_variables)

    SW.modifyGlobalVar(
        list(global_variables), [70, 120, 45], ["mm"] * len(global_variables)
    )


if __name__ == "__main__":
    main()
Wobei ich mal vermute man sollte prüfen, dass die Anzahl der Elemente in `global_variables` 3 ist. Und in der erwarteten Reihenfolge vielleicht auch.
selters
User
Beiträge: 4
Registriert: Dienstag 28. Juni 2022, 15:19

narpfel hat geschrieben: Dienstag 28. Juni 2022, 17:28 In deinem Code kommt kein `getGlobalVariables` vor? Bitte zeige genau den Code, den du ausführst (nicht irgendwas ähnliches) und genau den vollständigen Traceback, der angezeigt wird. Beides per Copy-Paste, nicht abtippen. Sonst kann man nicht effizient helfen und muss raten, ob der Unterschied zwischen Erwartung, Code und Exception nur ein Fehler in der Fragestellung ist oder tatsächlich das Problem.
Du hast vollkommen Recht. Danke Dir, ich habe den bearbeitet. Hoffentlich ist der jetzt verständlicher.
narpfel
User
Beiträge: 643
Registriert: Freitag 20. Oktober 2017, 16:10

@selters: Das ist ein Bug in der Bibliothek. In der von dir Verlinkten Version auf Github heißt die Funktion noch `getGlobalVariables`, in der Version, die du installiert hast (wahrscheinlich v1.4 von PyPI) ist die Funktion in `getGlobalVars` umbenannt worden, aber `modifyGlobalVar` wurde nicht angepasst und da wird immer noch auf `getGlobalVariables` zugegriffen. Entweder musst du das also selbst fixen oder ein Issue in dem Github-Repo deswegen aufmachen.
selters
User
Beiträge: 4
Registriert: Dienstag 28. Juni 2022, 15:19

narpfel hat geschrieben: Dienstag 28. Juni 2022, 19:05 @selters: Das ist ein Bug in der Bibliothek. In der von dir Verlinkten Version auf Github heißt die Funktion noch `getGlobalVariables`, in der Version, die du installiert hast (wahrscheinlich v1.4 von PyPI) ist die Funktion in `getGlobalVars` umbenannt worden, aber `modifyGlobalVar` wurde nicht angepasst und da wird immer noch auf `getGlobalVariables` zugegriffen. Entweder musst du das also selbst fixen oder ein Issue in dem Github-Repo deswegen aufmachen.
Danke dir vielmals. Könntest du mir mal vielleicht noch verraten, wie ich das ohne Forken fixen kann?
__deets__
User
Beiträge: 14494
Registriert: Mittwoch 14. Oktober 2015, 14:29

Gar nicht. Entweder selbst reparieren, oder warten, bis der Issue gefixt ist. Gibt’s nix dazwischen.
Benutzeravatar
__blackjack__
User
Beiträge: 13006
Registriert: Samstag 2. Juni 2018, 10:21
Wohnort: 127.0.0.1
Kontaktdaten:

Man könnte noch versuchen ob die Version vor dem Bug noch funktioniert.
“Most people find the concept of programming obvious, but the doing impossible.” — Alan J. Perlis
Qubit
User
Beiträge: 128
Registriert: Dienstag 7. Oktober 2008, 09:07

selters hat geschrieben: Mittwoch 29. Juni 2022, 05:44
narpfel hat geschrieben: Dienstag 28. Juni 2022, 19:05 @selters: Das ist ein Bug in der Bibliothek. In der von dir Verlinkten Version auf Github heißt die Funktion noch `getGlobalVariables`, in der Version, die du installiert hast (wahrscheinlich v1.4 von PyPI) ist die Funktion in `getGlobalVars` umbenannt worden, aber `modifyGlobalVar` wurde nicht angepasst und da wird immer noch auf `getGlobalVariables` zugegriffen. Entweder musst du das also selbst fixen oder ein Issue in dem Github-Repo deswegen aufmachen.
Danke dir vielmals. Könntest du mir mal vielleicht noch verraten, wie ich das ohne Forken fixen kann?
Vielleicht mit einer neuen Referenz..

Code: Alles auswählen

SW.getGlobalVariables = SW.getGlobalVars
Antworten