Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4151

Python • Re: How to use gpiod library when I activate python3-venv

$
0
0
What error are you seeing?

The gpiod installed by Raspberry Pi OS is v1.6.3, while the version you will get from pip is the latest, v2.1.3, unless you explicitly specify otherwise. The code you are running uses the gpiod v1 API, and the gpiod v2 API is different, so my guess is you are getting errors due to using v1 calls with the v2 module.

What does

Code:

pip show gpiod
report in your venv?

Assuming that is the problem, you have a few options:
- import your system installed package into your venv when you create it using the --system-site-packages option (easiest - unless there are other packages you don't want imported).
- convert your code to use the v2 API (best long term solution - if you are writing Python use the latest gpiod from PyPI rather than the old one Raspberry Pi OS provides).
- explicitly install a v1 version from PyPI:

Code:

pip3 install gpiod==1.5.4
That is the most recent available v1 on PyPI, and the difference between v1.5 and v1.6 probably isn't relevant for you.

Statistics: Posted by warthog618 — Wed May 29, 2024 6:35 am



Viewing all articles
Browse latest Browse all 4151

Trending Articles