我的python代码使用了pymodbus库,使用时的引入如下
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
后来新拿到一台设备,系统更新过,跑之前的代码一直报错
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
ModuleNotFoundError: No module named 'pymodbus.client.sync'
开始是使用pip3安装库
(GConnect-X8OCDuN_) pi@Gpm-OS:/ $ pip3 install -U pymodbus
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement 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/simple
ERROR: Could not find a version that satisfies the requirement pymodbus-2.5.5
ERROR: No matching distribution found for pymodbus-2.5.5
居然没有2.5.5版本,见鬼了,然后到pypi上去找,pymodbus · PyPI,发现真的没有,只能安装一个接近的
pip3 install pymodbus==2.5.3文章来源:https://www.toymoban.com/news/detail-685586.html
顺利完成文章来源地址https://www.toymoban.com/news/detail-685586.html
到了这里,关于No module named ‘pymodbus.client.sync‘解决方式的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!