我的python代码使用了pymodbus库,使用时的引入如下
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
后来新拿到一台设备,系统更新过,跑之前的代码一直报错
from pymodbus.client.sync import ModbusSerialClient as ModbusClientModuleNotFoundError: No module named 'pymodbus.client.sync'
开始是使用pip3安装库
(GConnect-X8OCDuN_) pi@Gpm-OS:/ $ pip3 install -U pymodbusLooking in indexes: https://pypi.org/simple, https://www.piwheels.org/simpleRequirement already satisfied: pymodbus in /home/pi/.local/share/virtualenvs/GConnect-X8OCDuN_/lib/python3.9/site-packages (3.2.2)Collecting pymodbus Using cached https://www.piwheels.org/simple/pymodbus/pymodbus-3.2.2-py3-none-any.whl (154 kB) Using cached https://www.piwheels.org/simple/pymodbus/pymodbus-3.2.1-py3-none-any.whl (154 kB)Requirement already satisfied: setuptools<66.0.0 in /home/pi/.local/share/virtualenvs/GConnect-X8OCDuN_/lib/python3.9/site-packages (from pymodbus) (44.1.1)
但是依然报错,后面使用pip3 list查看了下pymodbus的版本,打印如下
pymodbus 3.2.2
又找了老板子,看到是2.5.5的,那就好办了,直接上命令
pip3 install pymodbus==2.5.5
结果又出意外
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simpleERROR: Could not find a version that satisfies the requirement pymodbus-2.5.5ERROR: No matching distribution found for pymodbus-2.5.5
居然没有2.5.5版本,见鬼了,然后到pypi上去找,pymodbus · PyPI,发现真的没有,只能安装一个接近的
pip3 install pymodbus==2.5.3
顺利完成
来源地址:https://blog.csdn.net/itolddd9720/article/details/130200902