Python 无法在库中导入模块

Python unable to import module within library

我正在尝试使用 PyQt5 的 QSerialPort 模块。我发现的所有内容都表明包含 QSerialPort 的 QtSerial 应该与 PyQt5 一起提供。例如,

>>> from PyQt5 import QtSerial
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'QtSerial' from 'PyQt5' (/usr/lib/python3.8/site-packages/PyQt5/__init__.py)

我试过从内部 PyCharm 以及在命令行上使用 pip 安装 PyQt5。我试过升级 pip 并重新安装 PyQt5。我可以使用 PyQt5 的其他模块,例如 PyQt5.QtWidgets 导入没有任何问题。我还尝试从 AUR(我使用的是 Archlinux)安装 qt5-serialport-595qt51-serialport,但无济于事。

当我进入命令行和 运行 $ pip list -v PyQt5 时我可以看到 PyQt5 安装在 /usr/lib/python3.8/site-packages/ 并且当我在那里查看时,我可以看到文件 /usr/lib/python3.8/site-packages/PyQt5/QtSerialPort.abi3.so 存在。但是我也无法导入 PyQt5.QtSerial 因为它也没有找到,尽管消息略有不同:ImportError: libQt5SerialPort.so.5: cannot open shared object file: No such file or directory

这不是导入语句中的拼写错误造成的。我几乎尝试了字母 Q 和 T 以及单词 Serial 和 Port 的所有可能排列。如何使用PyQt5的串口模块?

出于某种原因,基于 this Archlinux forums post I ran pacman -Si python-pyqt5 which gave me a list of optional deps that included the line qt5-serialport: QtSerialPort so I used yay to install qt5-serialport. This is distinct from qt51-serialport, qt5-serialport-595, and in fact any of the AUR packages with serialport in the name that can be found by searching the AUR site。现在,当我在命令行上使用 python 时,我可以 from PyQt5.QtSerialPort import QSerialPort 而没有错误。

我应该注意到,https://pypi.python.org/simple 的软件包 repo(PyCharm 用于查找可安装软件包、可搜索的 AUR 列表和 pip 似乎都没有显示 qt5-serialport 作为一个选项。因此,即使我下载了它并且 python 可以从命令行找到它,它仍然没有被 PyCharm 导入,这是一个单独的问题。