Installation and Environment Setup#
For background information about pypylon, see the Introduction.
Installing the pylon Software Suite#
Install the Basler pylon Software Suite together with pypylon and required supplementary packages, e.g., for 3D cameras.
Info
The pypylon wheel package already includes the pylon C++ runtimes and vTools. This is sufficient for using pypylon and works immediately for transport layers that don't require any additional drivers.
You can download the pylon Software Suite as well as any additional supplementary packages, e.g., for 3D cameras, from the Basler website if required.
The installation wizard of the pylon Software Suite guides you through the process and allows you to decide which components to install. The following components are recommended:
- USB/GigE drivers
- CXP GenTL producer and drivers (if using CXP cameras)
- pylon Viewer
Installing pypylon#
pypylon is available from PyPi. To install it, run the following command:
When you run pip install on some systems, you may see something like this:
error: externally-managed-environment × This environment is externally managed To install Python packages system-wide, use your system package manager, for instance on Ubuntu23.04+.
This means that your operating system manages the Python installation. It helps prevent pip from changing system packages.
Alternative 1: Virtual Environment (Recommended)#
Python "virtual environments" allow Python packages to be installed in an isolated location for a particular application, rather than being installed globally. Using venv to install in folder DIR you need to perform following steps:
python3 -m venv <DIR>
source <DIR>/bin/activate # MacOS/ Linux
<DIR>\Scripts\activate # Windows
pip install pypylon
deactivate
This works the same way inside Docker, WSL, Raspberry Pi, and Conda setups. Each project gets its own dependency tree, and upgrades in one project never affect another.
Alternative 2: System-Wide Installation#
sudo python3 -m pip install pypylon --break-system-packages
This approach is rather simple and the module is available to all users immediately. Besides requiring root privileges, however, it also has the following drawbacks.
- It may conflict with Debian package management.
- Future Debian or Python updates may break things.
Generally speaking, this approach is discouraged on modern Debian systems.
Verifying the Installation#
To verify the pypylon installation, run the following command:
from pypylon import pylon
factory = pylon.TlFactory.GetInstance()
devices = factory.EnumerateDevices()
print("Detected:", len(devices))
GigE Optimization#
If you're planning to use GigE cameras, the following optimizations are recommended:
- Use a dedicated network interface card (NIC)
- Enable jumbo frames (MTU 9000)
- Disable energy saving
Distributing pypylon#
Pypylon provides a complete pylon runtime. Therefore, it's not necessary to install the pylon Software Suite.
In case you also require a camera or frame grabber driver, take a look in the pylon Deployment Guide.