我想在树莓派中使用XBee python库。当我运行代码时,遇到以下错误

    Traceback (most recent call last):
       File "XBeeMQTT-V1.py", line 25, in <module>
       from digi.xbee.devices import XBeeDevice
       File "build/bdist.linux-armv7l/egg/digi/xbee/devices.py", line 22, in <module>
       File "build/bdist.linux-armv7l/egg/digi/xbee/serial.py", line 15, in <module>
    ImportError: cannot import name Serial


我在python代码中导入了serial和xbee-digi并将两个库都安装在树莓派上(usr / local / lib / python2.7 / dist-packages)。
知道错误源于何处?

最佳答案

要解决此问题,请按照下列步骤操作:

sudo apt-get install python3-pip && sudo apt-get install python3-serial


然后转到/usr/local/lib/python3.x/dist-packages并运行

sudo pip3 install setuptools


最后

sudo pip3 install digi-xbee

关于python - 在Raspberry Pi3中使用XBee python库时出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50808574/

10-11 15:44