Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vinityadava opened this issue Dec 7, 2023 · 8 comments
Open

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

vinityadava opened this issue Dec 7, 2023 · 8 comments

Comments

@vinityadava
Copy link

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

@MaffooClock
Copy link

MaffooClock commented Dec 8, 2023

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
Copy link
Author

vinityadava commented Dec 8, 2023

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

vinityadava commented Dec 8, 2023

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

@MaffooClock
Copy link

MaffooClock commented Dec 11, 2023

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:

import gpiod

... 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
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants