0

我一直在 Python 2.7 中使用 lirc,在 Rpi3 上使用 Python 3.5.3。现在我已经从源代码安装了 Python 3.8.7,但是我无法在这个版本的 Python 中使用 lirc,但它仍然可以在 Python 3.5 中使用。apt-get 报告 python3-lirc 已经是最新版本(1.2.1-2)。如何在 Python 3.5 和 3.8 中获得 lirc 工作?

pi@RPi3:~ $ python
Python 3.8.7 (default, Jan  7 2021, 08:59:27)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lirc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lirc'
>>>

pi@RPi3:~ $ python3.5
Python 3.5.3 (default, Nov 18 2020, 21:09:16)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lirc
>>> sockid=lirc.init("myProg", blocking = False)
>>>
4

2 回答 2

1

这意味着您lirc只安装了两个 python 之一。

使用 Python 3.8 中的 pip 进行安装lirc,以便 Python 3.8 也可以访问该模块。

于 2021-01-07T16:58:46.240 回答
0

必须使用 pip 卸载模块 lirc,然后在使用 pip 安装 cyhton 后,可以按照https://github.com/tompreston/python-lirc/issues/26中所述在 Python 3,8 中安装 python-lirc 。

于 2021-01-08T14:39:27.337 回答