pythonpython-3.xtwincattwincat-ads

Windows 10 Python pyads library error: Could not find module 'TcAdsDll.dll'


I am trying to use pyads library in my Windows 10 computer to communicate with my Beckhoff PLC.

I have installed the library with "pip install pyads". The version I have installed is 3.3.9.

The version of Python I am using is 3.8.10.

When I do "import pyads" the following error appears:

    import pyads
  File "C:\Users\usuSAT026\AppData\Local\Programs\Python\Python38\lib\site-packages\pyads\__init__.py", line 10, in <module>
    from .ads import (
  File "C:\Users\usuSAT026\AppData\Local\Programs\Python\Python38\lib\site-packages\pyads\ads.py", line 49, in <module>
    from .pyads_ex import (
  File "C:\Users\usuSAT026\AppData\Local\Programs\Python\Python38\lib\site-packages\pyads\pyads_ex.py", line 69, in <module>
    _adsDLL = ctypes.WinDLL("TcAdsDll.dll")  # type: ignore
  File "C:\Users\usuSAT026\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'TcAdsDll.dll' (or one of its dependencies). Try using the full path with constructor syntax.

I don't have TwinCAT installed on my computer. The TwinCAT version I'm using in the PLC is v3.1.4024.25.

What can I do?

Thanks!


Solution

  • You must have at least the ADS version of TwinCat installed on your PC for pyads to work (or for any ADS communication to work for that matter) and you must then create a route between the PC and the PLC using the route dialog. Beckhoff have three versions of Twincat, XAE ( Full engineering SW), XAR (just the twincat runtime) and the ADS version used to route the communication traffic between different twincat devices.

    The latest version of this can be downloaded from the beckhoff website here:

    https://www.beckhoff.com/en-en/products/automation/twincat/tc1xxx-twincat-3-base/tc1000.html