ich arbeite seit einiger Zeit an einem Programm, dass anhand einer Mathematischen Optimierung Ergebnisse liefern soll.
Für das ganze Projekt nutze ich
- Visual Studio Code
- Python 3.11.2 64-bit
- Windows 10, Core i7-12850HX
Ich habe mir mit tkinter eine umfangreiche UI erstellt, die bestens funktioniert.
Wenn ich meinen Code in VSC ausführe funktioniert auch alles. Selbst die Mathematische Optimierung läuft sauber durch und liefert mir die gewünschten Ergebnisse.
Mein nächster Schritt war nun, eine exe zu erstelle, damit meine Arbeitskollegen, das Programm auch nutzen können, ohne VSC, Python usw. zu benötigen.
Dafür habe ich pyinstaller genutzt. Nach anfänglichen Schwierigkeiten, habe ich es auch hinbekommen und mein Programm ist zu 99% lauffähig. Ich kann die UI in allen Bereichen nutzen, habe Zugriff auf meine SqliteDB usw.
Nur die Mathematische Optimierung funktioniert nicht!
Wenn ich mein Programm in der Konsole starte, bekomme ich sobald ich die Berechnung starte, folgende Meldung:
Code: Alles auswählen
Exception in thread Thread-2:
Traceback (most recent call last):
File "threading.py", line 1038, in _bootstrap_inner
File "optimization.py", line 1078, in run
File "mip\model.py", line 87, in __init__
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "mip\cbc.py", line 603, in <module>
NameError: name 'cbclib' is not defined
Code: Alles auswählen
Osi_getNumCols = cbclib.Osi_getNumCols
Code: Alles auswählen
if os_is_64_bit:
libfile = os.path.join(pathlib, "cbc-c-darwin-x86-64.dylib")
if not libfile:
raise NotImplementedError("You operating system/platform is not supported")
old_dir = os.getcwd()
os.chdir(pathlib)
cbclib = ffi.dlopen(libfile)
Code: Alles auswählen
try:
pathmip = dirname(mip.__file__)
pathlib = os.path.join(pathmip, "libraries")
libfile = ""
# if user wants to force the loading of an specific CBC library
# (for debugging purposes, for example)
if "PMIP_CBC_LIBRARY" in os.environ:
libfile = os.environ["PMIP_CBC_LIBRARY"]
pathlib = dirname(libfile)
if platform.lower().startswith("win"):
if pathlib not in os.environ["PATH"]:
os.environ["PATH"] += ";" + pathlib
else:
if "linux" in platform.lower():
if os_is_64_bit:
pathlibe = pathlib
libfile = os.path.join(pathlib, "cbc-c-linux-x86-64.so")
if not exists(libfile):
pathlibe = pathlib
libfile = os.path.join(pathlib, "cbc-c-linux-x86-64.so")
pathlib = pathlibe
else:
raise NotImplementedError("Linux 32 bits platform not supported.")
elif platform.lower().startswith("win"):
if os_is_64_bit:
pathlibe = os.path.join(pathlib, "win64")
libfile = os.path.join(pathlibe, "cbc-c-windows-x86-64.dll")
if exists(libfile):
if pathlibe not in os.environ["PATH"]:
os.environ["PATH"] = pathlibe + ";" + os.environ["PATH"]
else:
pathlibe = pathlib
libfile = os.path.join(pathlibe, "cbc-c-windows-x86-64.dll")
if pathlibe not in os.environ["PATH"]:
os.environ["PATH"] = pathlibe + ";" + os.environ["PATH"]
pathlib = pathlibe
else:
raise NotImplementedError("Win32 platform not supported.")
elif platform.lower().startswith("darwin") or platform.lower().startswith(
"macos"
):
if os_is_64_bit:
libfile = os.path.join(pathlib, "cbc-c-darwin-x86-64.dylib")
if not libfile:
raise NotImplementedError("You operating system/platform is not supported")
Ich bin jetzt seit Wochen auf der Suche nach einer Lösung, komme aber zu keiner Lösung.C:\Users\Dominik\AppData\Local\Programs\Python\Python311\Lib\site-packages\mip\libraries\win64\cbc-c-windows-x86-64.dll
C:\Users\q180341\AppData\Local\Programs\Python\Python311\Lib\site-packages\mip\libraries\cbc-c-darwin-x86-64.dylib
Diverses googlen, Foren durchsuchen und ChatGPT befragen habt mich nicht weiter gebracht. Das einzige was ich bisher rausgefunden habe ist, dass ich nicht der einzige bin. Diesen Fehler gibt es wohl häufiger, aber eine umsetzbare Lösung ist noch nicht dabei gewesen. Bei einigen scheint es auch ohne Probleme zu funktionieren....
Vielleicht hat hier jemand Erfahrung, oder hat eine Idee woran es noch liegen kann. Evtl. ist die Lösung ganz einfach und ich mache einfach irgendetwas falsch...
Ich bin für jede Hilfe dankbar.