1

I want to use XBee python library in raspberry pi. when I run the code, I encounter the following Error

    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

I import serial and xbee-digi in the python code and install both library on raspberry pi (usr/local/lib/python2.7/dist-packages). have any idea where the error stems from?

  • install pyserial – eyllanesc Jun 12 '18 at 02:51
  • I did it. In usr/local/lib/python2.7/dist-packages I have folder serial. this is what you mean? running the command pip install pyserial, I got this message: Requirement already satisfied: pyserial in /usr/local/lib/python2.7/dist-packages You are using pip version 9.0.3, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. –  Jun 12 '18 at 02:53
  • You must not create the folder, you must install pyserial – eyllanesc Jun 12 '18 at 02:54
  • execute `sudo apt-get install python-serial` – eyllanesc Jun 12 '18 at 02:55
  • after running the cmd (sudo apt-get install python-serial), I got the same error as previous –  Jun 12 '18 at 02:57
  • Well then report it as a bug. :) – eyllanesc Jun 12 '18 at 02:57
  • In the documentation of the library, it is mentioned that it need python 3. but the library installed on python 2.7, Do you think it may cause the problem? and if so, how to solve it. –  Jun 12 '18 at 03:09
  • 1
    Then install for python 3: `sudo apt-get install python3-pip && sudo apt-get install python3-serial && sudo pip install xbee-digi` – eyllanesc Jun 12 '18 at 03:11
  • when I run the cmd sudo pip3 install xbee-digi got Collecting xbee-digi Could not find a version that satisfies the requirement xbee-digi (from versions: ) No matching distribution found for xbee-digi –  Jun 12 '18 at 03:27
  • 1
    excuse me, execute `sudo pip3 install digi-xbee` – eyllanesc Jun 12 '18 at 03:27

1 Answers1

1

To solve the problem, follow the steps:

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

then go to /usr/local/lib/python3.x/dist-packages and run

sudo pip3 install setuptools

and finally

sudo pip3 install digi-xbee