hidapi 安装在(英特尔)MacOS Ventura 13.6.1 上
brew install hidapi
我正在将旧的 python2 脚本移植到 python3。片段:
from __future__ import print_function
import hid, sys, time, datetime, mysql.connector, os.path, commands
h = hid.device()
commands 模块在 Python3 中已弃用(将不起作用)
user@iMac% python3
达尔文上的 Python 3.10.8(v3.10.8:aaaf517424,2022 年 10 月 11 日,10:14:40)[Clang 13.0.0 (clang-1300.0.29.30)] 输入“帮助”、“版权”、“制作人员”或“许可证”以获取更多信息。
~>>> import hid
回溯(最近一次调用最后一次):文件“”,第 1 行,在 ModuleNotFoundError:没有名为“hid”的模块
如何确认'hid'在python3中没有被弃用? 'commands' 在 python3 中已弃用
如果不弃用:可以执行哪些测试来确定 ModuleNotFoundError 的根本原因?
根据 PyPI (Python Package Index),
hid
Python 模块未预安装,必须使用 pip 安装:pip install hid
。 Pip 通常默认安装在最新版本的 Python 上。您可以通过运行 pip -V
或 python3 -m pip -V
进行检查。如果不是,请参阅安装说明。安装模块后,导入它应该没有问题。