The free CAN Software API (Application Programming Interface) for Windows®
-
suresheps
- Posts: 1
- Joined: Thu 19. Sep 2019, 19:00
Post
by suresheps » Thu 19. Sep 2019, 19:07
Hi, I Am trying to use PCAN Basic library. So stared with "PCANBasicExample.pyw" but i am getting below error
Code: Select all
objPCAN = PCANBasic()
File "C:\Users\Downloads\pcan-basic\PCAN-Basic API\Samples\Python\PCANBasic.py", line 348, in __init__
self.__m_dllBasic = windll.LoadLibrary("PCANBasic")
File "C:\Python27\lib\ctypes\__init__.py", line 444, in LoadLibrary
return self._dlltype(name)
File "C:\Python27\lib\ctypes\__init__.py", line 366, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
somehow script is not recognizing the DLL, please help
Last edited by
K.Wagner on Fri 20. Sep 2019, 08:28, edited 1 time in total.
Reason: Code formatting for better reading
-
K.Wagner
- Software Development

- Posts: 1080
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Fri 20. Sep 2019, 08:35
Hello,
please check that:
- you have installed PCAN-Basic with our PEAK-Drivers setup, or that you have copied the PCANBasic.dll to the same folder in where your python file is located.
- the platform of your python compiler and the used dll are the same, i.e. both 32-bit or both 64-bit. By python you see this in the header of the python console, at start. For PCAN-Basic you can see this in the file properties: richt-mouse click on the file, select "Properties" and go to the tab "Details". The description text shows the platform for which the dll was compiled.
Best regards,
Keneth
-
efariv
- Posts: 3
- Joined: Tue 24. Sep 2019, 00:41
Post
by efariv » Tue 24. Sep 2019, 01:59
I'm encountering the same issue even after verifying the two things you've noted above. However, I'm seeing the following different error message:
Code: Select all
Traceback (most recent call last):
File ".\readPCAN2.py", line 3, in <module>
from PCANBasic import *
File "C:\SW_WIP\PCAN\scripts\PCANBasic.py", line 22, in <module>
from ctypes import *
File "C:\Python27\lib\ctypes\__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: DLL load failed: %1 is not a valid Win32 application.
This is using the latest PCAN-Basic API downloaded from the website.
-
K.Wagner
- Software Development

- Posts: 1080
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Tue 24. Sep 2019, 08:52
Hello,
please check again. The error message is clearly saying that "ImportError: DLL load failed: %1 is not a valid Win32 application". This is due to a mix-up of the libraries (Win32 vs. x64), i.e. you are using a 32-bit python interpreter, but a x64 PCANBasic.dll
If you have manually copied the PCANBasic.dll to your project folder, then check that it is the Win32 version of it. Just right-click with the mouse on the PCANBasic.dll file and check the description of it in the tab "Details".
Best regards,
Keneth