The free CAN Software API (Application Programming Interface) for Windows®
-
Bobity
- Posts: 5
- Joined: Thu 10. Dec 2020, 17:08
Post
by Bobity » Sat 20. Feb 2021, 17:42
I have a simple python program using PCANBasic. It fails on execution with the following:
Code: Select all
C:\My_Docs\...\NF_Processing\venv\Scripts\python.exe C:/My_Docs/.../NF_Processing/PCAN_Test.py
Traceback (most recent call last):
File "C:/My_Docs/.../NF_Processing/PCAN_Test.py", line 28, in <module>
objPCAN = PCANBasic()
File "C:\My_Docs\...\NF_Processing\PCANBasic.py", line 378, in __init__
self.__m_dllBasic = windll.LoadLibrary("C:\\MY Docs\\Phd\\PCAN-Basic API\\x64\\PCANBasic")
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\ctypes\__init__.py", line 442, in LoadLibrary
return self._dlltype(name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
Process finished with exit code 1
The python program PCAN_Test.py is:
Code: Select all
import sys
#import pyodbc
import numpy as np
import pandas as pd
import random
import time
import ctypes
from ctypes import *
#from ctypes import wintypes
sys.path.append('''C:\Python34\Projects\ARM''')
sys.path.append('''C:\Python34\Lib\site-packages\python_can-1.4-py3.4.egg\can\interfaces''')
sys.path.append('''C:\My_Docs\PhD\PCAN-Basic API\x64''')
#sys.path.append('''C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Lib\ctypes''')
#sys.path.append(['C:\My_Docs\PhD\PCAN-Basic API\x64\'])
from PCANBasic import *
channel = PCAN_USBBUS1
#channel = PCAN_USBBUS2
baud = PCAN_BAUD_500K
timeprev = 0.0
## The Plug & Play Channel (PCAN-USB) is initialized
##
#objPCAN =# The Plug & Play Channel (PCAN-USB) is initialized
#
objPCAN = PCANBasic()
result = objPCAN.Initialize(channel, baud)
There is probably something very simple I'm doing wrong but have no idea what it is.
Thanks
Rob
Last edited by
M.Gerber on Mon 22. Feb 2021, 10:42, edited 1 time in total.
Reason: Inserted [code] tags for improved readability
-
M.Heidemann
- Sales & Support

- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Post
by M.Heidemann » Mon 22. Feb 2021, 07:32
Hello,
Is this error reproducable, if the PCANBasic API was installed using the PEAK-Device Driver Setup?
Dowload Peak Device Driver Setup:
https://www.peak-system.com/quick/DrvSetup
Make sure to check the "PCANBasic" option during the setup:

- DriverSetupPcanBasic.PNG (31.46 KiB) Viewed 9473 times
Please report back to us if this was able to resolve the issue.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
-
Bobity
- Posts: 5
- Joined: Thu 10. Dec 2020, 17:08
Post
by Bobity » Sat 27. Feb 2021, 16:26
Marvin,
Tried what you suggested - Rebooted after. Still get a similar error:
Code: Select all
C:\My_Docs\PhD\NF_Processing\venv\Scripts\python.exe C:/My_Docs/PhD/NF_Processing/PCAN_Test.py
Traceback (most recent call last):
File "C:/My_Docs/PhD/NF_Processing/PCAN_Test.py", line 28, in <module>
objPCAN = PCANBasic()
File "C:\My_Docs\PhD\NF_Processing\PCANBasic.py", line 378, in __init__
self.__m_dllBasic = windll.LoadLibrary("C:\\MY Docs\\Phd\\PCAN-Basic API\\x64\\PCANBasic")
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\ctypes\__init__.py", line 442, in LoadLibrary
return self._dlltype(name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
Process finished with exit code 1
no external download allowed - removed by admin
Thanks
Rob
Last edited by
M.Gerber on Mon 1. Mar 2021, 07:31, edited 1 time in total.
Reason: Inserted [Code] tag for improved readability
-
PEAK-Support
- Sales & Support

- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Post
by PEAK-Support » Sun 28. Feb 2021, 11:39
You mix up 32/64 Bit DLLs. Search on your PC in all folders the file "pcanbasic.dll " - delete them all.
Run the Setup again as my colleauge wrote in the last post - select PCANBasic API.
If you want to understand read this:
viewtopic.php?f=116&t=886
and
viewtopic.php?f=41&t=870
We use Python (2.x and 3.x) with 32 and 64 Bit DLLs and Runtime, since years - it works without any problem if the environment is setup correct.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
-
Bobity
- Posts: 5
- Joined: Thu 10. Dec 2020, 17:08
Post
by Bobity » Thu 4. Mar 2021, 16:45
I ended up changing the reference to PCANBasic in PCANBasic.py thus which solved the problem:
if platform.system() == 'Windows':
# self.__m_dllBasic = windll.LoadLibrary("C:\\MY Docs\\Phd\\PCAN-Basic API\\x64\\PCANBasic")
# self.__m_dllBasic = windll.LoadLibrary("C:\\Windows\\SysWOW64\\PCANBasic")
self.__m_dllBasic = windll.LoadLibrary("C:\\Windows\\System32\\PCANBasic")
Thanks for your help
Rob
-
PEAK-Support
- Sales & Support

- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Post
by PEAK-Support » Thu 4. Mar 2021, 16:57
Also a solution!
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------