$ pip install python-can
As most likely you will want to interface with some hardware, you may also have to install platform dependencies. Be sure to check any other specifics for your hardware in CAN Interface Modules.
Reasonably modern Linux Kernels (2.6.25 or newer) have an implementation
socketcan. This version of python-can will directly use socketcan
if called with Python 3.3 or greater, otherwise that interface is used
python-can using the Kvaser CANLib SDK as the backend:
To use the PCAN-Basic API as the backend (which has only been tested with Python 2.7):
- Download the latest version of the PCAN-Basic API.
PCANBasic.dllfrom the Win32 subfolder of the archive or the x64 subfolder depending on whether you have a 32-bit or 64-bit installation of Python.
PCANBasic.dllinto the working directory where you will be running your python script. There is probably a way to install the dll properly, but I’m not certain how to do that.
Note that PCANBasic API timestamps count seconds from system startup. To
convert these to epoch times, the uptime library is used. If it is not
available, the times are returned as number of seconds from system
startup. To install the uptime library, run
pip install uptime.
Installing python-can in development mode¶
A “development” install of this package allows you to make changes locally or pull updates from the Mercurial repository and use them without having to reinstall. Download or clone the source repository then:
python setup.py develop