Vergessen Sie jedes Mal und verbringen Sie Zeit damit, jedes Mal eine Lösung zu suchen und zu finden. Machen Sie sich vorerst eine Notiz.
Linux
https://stackoverflow.com/questions/24343557/cant-find-snap7-library-linux
Trotzdem konnte ich es aus irgendeinem Grund nicht importieren. Und wenn Sie den Fehler wieder sehen. Vielleicht gibt es etwas gemeinsam.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/snap7/client.py", line 29, in __init__
self.library = load_library()
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 48, in load_library
return Snap7Library(lib_location).cdll
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 40, in __init__
raise Snap7Exception(msg)
snap7.exceptions.Snap7Exception: can't find snap7 library. If installed, try running ldconfig
Ich konnte sicher gehen!
class Snap7Library(object):
"""
Snap7 loader and encapsulator. We make this a singleton to make
sure the library is loaded only once.
"""
_instance = None
def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = object.__new__(cls)
cls._instance.lib_location = None
cls._instance.cdll = None
return cls._instance
def __init__(self, lib_location=None):
if self.cdll:
return
#Change here
#self.lib_location = lib_location or self.lib_location or find_library('snap7')
self.lib_location = 'your lib location'
if not self.lib_location:
msg = "can't find snap7 library. If installed, try running ldconfig"
raise Snap7Exception(msg)
self.cdll = cdll.LoadLibrary(self.lib_location)
Window
Dies.
The folder where the snap7.dll and .lib file are located must be present in the Enviroment variables of Windows.
https://stackoverflow.com/questions/33697263/python-snap7-windows-cant-find-snap7-library
Recommended Posts