Installation#
Install the can
package from PyPi with pip
or similar:
$ pip install python-can
Warning
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 Hardware Interfaces.
Many interfaces can install their dependencies at the same time as python-can
,
for instance the interface serial
includes the pyserial
dependency which can
be installed with the serial
extra:
$ pip install python-can[serial]
GNU/Linux dependencies#
Reasonably modern Linux Kernels (2.6.25 or newer) have an implementation
of socketcan
. This version of python-can will directly use socketcan
if called with Python 3.3 or greater, otherwise that interface is used
via ctypes.
Windows dependencies#
Kvaser#
To install python-can
using the Kvaser CANLib SDK as the backend:
Test that Kvaser’s own tools work to ensure the driver is properly installed and that the hardware is working.
PCAN#
Download and install the latest driver for your interface:
Windows (also supported on Cygwin)
Linux (also works without, see also Linux installation)
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 python-can[pcan]
.
This library can take advantage of the Python for Windows Extensions library if installed. It will be used to get notified of new messages instead of the CPU intensive polling that will otherwise have be used.
IXXAT#
To install python-can
using the IXXAT VCI V3 or V4 SDK as the backend:
Install IXXAT’s latest Windows VCI V3 SDK or VCI V4 SDK (Win10) drivers.
Test that IXXAT’s own tools (i.e. MiniMon) work to ensure the driver is properly installed and that the hardware is working.
NI-CAN#
Download and install the NI-CAN drivers from National Instruments.
Currently the driver only supports 32-bit Python on Windows.
neoVI#
Vector#
To install python-can
using the XL Driver Library as the backend:
Install the latest drivers for your Vector hardware interface.
Install the XL Driver Library or copy the
vxlapi.dll
and/orvxlapi64.dll
into your working directory.Use Vector Hardware Configuration to assign a channel to your application.
CANtact#
CANtact is supported on Linux, Windows, and macOS.
To install python-can
using the CANtact driver backend:
python3 -m pip install "python-can[cantact]"
If python-can
is already installed, the CANtact backend can be installed separately:
pip install cantact
Additional CANtact documentation is available at cantact.io.
CanViewer#
python-can
has support for showing a simple CAN viewer terminal application
by running python -m can.viewer
. On Windows, this depends on the
windows-curses library which can
be installed with:
python -m pip install "python-can[viewer]"
Installing python-can in development mode#
A “development” install of this package allows you to make changes locally or pull updates from the Git repository and use them without having to reinstall. Download or clone the source repository then:
python setup.py develop