Can't get python-can-viewer to run

Question:

I want to use python to read a can-bus and later on going to send messages on the bus via python(I’m a total python newbie, but have knowledge in C and C++). So I started with installing the python-can module via pip. First thing I wanted to try is only read messages from the bus with the python-can-viewer. I checked the connection with the firmware from peak and everything works fine I can see the heartbeat from my can device. But the can-viewer module wont start.

screenshot

Sorry that the error-massage is in German, it means:

[WinError 126] The specified module could not be found

I also tried to use a simple example from python-can

import can

can.rc['interface'] = 'pcan'
can.rc['channel'] = 'PCAN_USBBUS1'
can.rc['bitrate'] = 500000


def send_one():

    with can.interface.Bus() as bus:

        bus = can.interface.Bus()

        msg = can.Message(
            arbitration_id=0xC0FFEE, data=[0, 25, 0, 1, 3, 1, 4, 1], is_extended_id=True
        )

        try:
            bus.send(msg)
            print("Message sent on {bus.channel_info}")
        except can.CanError:
            print("Message NOT send")


if __name__ == "__main__":
    send_one()

I got the example from https://python-can.readthedocs.io/en/master/

I also get the same error, I also found that winerror 126 could be about missing ddls or libaries so I installed the x64 vc_redist from microsoft, but it didnt help https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

edit: forgot to mention this site https://python-can.readthedocs.io/en/3.3.2/installation.html

Asked By: tryanderror

||

Answers:

I found the problem, i didnt install the right dll in the windows/system32 folder, i downloaded the right PCAN API Basic Driver Software from https://www.peak-system.com/Downloads.76.0.html?&L=1

For someone with the same problem, download the basi API Driver for Windows and get the PCANbasic.DLL in the system32 folder (u need administrator rights)

Answered By: tryanderror