On Debian/Raspbian you only need lirc
package. It contains the lirc Python bindings package sources unpacked and as tar.gz file.
You can install the lirc Python bindings to a currently active venv is for example by this command:
pip3 install /usr/share/lirc/lirc-0.10.1.tar.gz
The command above works for Raspbian GNU/Linux 12 (bookworm), for your Linux distribution and lirc version you may have to adapt it.
Test scripts for testing functionality of lirc python bindings:
import lirc
print(lirc.get_default_socket_path())
Outputs /var/run/lirc/lircd
with lirc.RawConnection('/var/run/lirc/lircd') as conn:
press = conn.readline()
print(press)
If you omit the parameter '/var/run/lirc/lircd'
the default socket path printed by example 1 is used.
import lirc
with lirc.LircdConnection('mylirc') as conn:
while True:
string = conn.readline()
print(string)
The 'mylirc'
argument is taken form /etc/lirc/lircrc
where each key is defined. It is there defined as prog = mylirc
in each begin/end block.