Skip to content

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

Open
@vinityadava

Description

@vinityadava

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

Activity

MaffooClock

MaffooClock commented on Dec 8, 2023

@MaffooClock

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

vinityadava commented on Dec 8, 2023

@vinityadava
Author

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

MaffooClock commented on Dec 8, 2023

@MaffooClock

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

vinityadava commented on Dec 8, 2023

@vinityadava
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

MaffooClock commented on Dec 8, 2023

@MaffooClock

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

vinityadava commented on Dec 8, 2023

@vinityadava
Author

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

MaffooClock

MaffooClock commented on Dec 11, 2023

@MaffooClock

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

vinityadava commented on Dec 13, 2023

@vinityadava
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @MaffooClock@vinityadava

        Issue actions

          Error: cannot import name 'LoRaSpi' from 'LoRaRF' · Issue #19 · chandrawi/LoRaRF-Python