chandrawi / LoRaRF-Python

Python library for basic transmitting and receiving data using LoRa and FSK modem
MIT License
29 stars 15 forks source link

Error: cannot import name 'LoRaSpi' from 'LoRaRF' #19

Open vinityadava opened 7 months ago

vinityadava commented 7 months ago

I was installing the network node from network folder , but it throws this error when pressed run. Can anyone resolve it?

MaffooClock commented 7 months ago

You must be following the current examples; but those were refactored (commit 67cb5c9) after the v1.4.0 release (commit 86572c3), so they reference a new API that doesn't exist in the published version.

You have two options:

  1. Install the bleeding-edge version with:

    pip3 install git+https://github.com/chandrawi/LoRaRF-Python.git

    Note that you might get a No module named 'gpiod' exception with this version, so you'll need to install libgpiod -- if you're on Ubuntu/Debian, run sudo apt install python3-libgpiod.

  2. Stay with the current v1.4.0, but reference the examples from that version.

vinityadava commented 7 months ago

Thank you for that, I followed the same (1).

but now it says,

192 168 43 187 (raspberrypi) - RealVNC Viewer 08-12-2023 21_17_25

MaffooClock commented 7 months ago

Do you not have SPI enabled?

If you run ls /dev/spi*, you should see something like this: Screenshot 2023-12-08 at 12 07 21 PM

...if not, then you don't have SPI enabled (and that's why you see a "file not found" error).

vinityadava commented 7 months ago

Yes, I have enabled it.

192 168 43 187 (raspberrypi) - RealVNC Viewer 08-12-2023 23_46_11

Let me give you the context, I am using raspberrypi Zero w with Lora module SX1262. And I am trying to run transmitter,py file here.

MaffooClock commented 7 months ago

I am using raspberrypi Zero w with Lora module SX1262

Same! And mine is working.

After looking closer at the error message, I see a reference to gpiod/chip.py, but you shouldn't be using a module called "gpiod," I don't think -- I don't have that in my environment, anyway. Seems like your Python environment might be goofy. But I'm just guessing, not sure what else to advise.

vinityadava commented 7 months ago

Can you recommend what OS you are using? I am using raspberrypi OS(Legacy) with desktop 32 bit

MaffooClock commented 7 months ago

I'm using DietPi, 64-bit (bookworm). But its Apt uses the Debian repos, so it'd be the same as Raspbian (or legacy Raspberry Pi OS). But I don't think this is an OS issue.

I just noticed that LoRaRF is using gpiod: https://github.com/chandrawi/LoRaRF-Python/blob/67cb5c96fd4bb95db57e176590ced4b78b3f1192/LoRaRF/base.py#L2 ... so I was half-way wrong earlier.

So what happens if you run this?

python3 -c "import gpiod; print( gpiod.__file__ )"

For me, it returns /usr/lib/python3/dist-packages/gpiod.cpython-311-aarch64-linux-gnu.so -- a compiled shared object, not a straight Python file (which is consistent with what the Debian package installs for my system).

I would expect yours to return /usr/lib/python3/dist-packages/gpiod.cpython-311-i386-linux-gnu.so, and if so, then maybe just delete ~/.local/lib/python3.9/site-packages/gpiod?

vinityadava commented 7 months ago

Thanks @MaffooClock I resolved the issue by following above steps, and succesfully transmitting and receiving data.

Now i want to send the list of floats but it is showing the error Type error. I have mentioned it in issue 13 /issue #21

Can you help about it?