digidotcom / xbee-python

Python library to interact with Digi International's XBee radio frequency modules.
Mozilla Public License 2.0
183 stars 93 forks source link

GettingStarted Code Returns Cannot Import Name XbeeDevice #267

Closed stokes776 closed 2 years ago

stokes776 commented 2 years ago

ImportError: cannot import name 'XbeeDevice' from 'digi.xbee.devices' (/home/pi/xbee-python/digi/xbee/devices.py)

Hello, I am trying to run the Getting Started Python code on a Raspberry Pi 4B.

I am following this page: https://xbplib.readthedocs.io/en/latest/getting_started_with_xbee_python_library.html#run-your-first-xbee-python-application

Things I have done: I have done a full sudo apt-get update && sudo apt-get upgrade on a clean bullseye install. I installed python3. I installed pip. I ran pip install digi-xbee I ran pip install pyserial (already installed) I ran pip install srp I cloned the git repo (the command in the tutorial does not work), instead I used command git clone https://github.com/digidotcom/xbee-python.git

I then cd into the xbee-python directory.

From here, I launch python3, and get a prompt. I try the command 'from digi.xbee.devices import XbeeDevice and immediately get an ImportError.

image

Am I doing something wrong here? I know this is not the place for troubleshooting, but I think I followed the directions pretty precisely and ended up with an error on the first command.

tatianaleon commented 2 years ago

Hi @stokes776,

Try importing digi.xbee.devices.XBeeDevice (note the uppercase B in "XBeeDevice")

$ which python3
/media/tleon/data/git/xbee-gateway/xbee-mqtt/310venv/bin/python3
(310venv) [master] tleon:/media/tleon/data/git/xbee-gateway/xbee-mqtt$ python3
Python 3.10.2 (main, Feb  9 2022, 12:40:46) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from digi.xbee.devices import XBeeDevice
>>> 

Best Regards, Tatiana