Oubliez cela à chaque fois et passez du temps à chercher et à trouver une solution à chaque fois. Prenez note pour le moment.
Linux
https://stackoverflow.com/questions/24343557/cant-find-snap7-library-linux
--Téléchargez d'abord la bibliothèque SNAP7 (cet exemple est 1.2.1) - wget http://sourceforge.net/projects/snap7/files/1.2.1/snap7-full-1.2.1.tar.gz/download
Pourtant, je ne pouvais pas l'importer pour une raison quelconque. Et si vous voyez à nouveau l'erreur. Il y a peut-être quelque chose en common.py!
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
J'ai pu y aller en toute sécurité!
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
Cette.
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