pySerialTransfer icon indicating copy to clipboard operation
pySerialTransfer copied to clipboard

Issue with relative import from no known package

Open ericshear26 opened this issue 9 months ago • 4 comments
trafficstars

I'm still working on the same project. To give myself a better understanding of how pySerialTransfer and SerialTransfer.h work, I'm running each example in the documentation. I am using tx_data.py with rx_data.ino and rx_data.py with tx_data.ino. Every time I run rx_data or tx_data on Python, I get this error:

(base) Eric@CHE-NAR-2G5L2C0 ~ % /usr/local/bin/python3 "/Users/Eric/Desktop/Dissertation/Codes & Scripts/Python/rx_data.py" Traceback (most recent call last): File "/Users/Eric/Desktop/Dissertation/Codes & Scripts/Python/rx_data.py", line 2, in from pySerialTransfer import pySerialTransfer as txfer File "/Users/Eric/Desktop/Dissertation/Codes & Scripts/Python/pySerialTransfer.py", line 11, in from .CRC import CRC ImportError: attempted relative import with no known parent package

This happened even though I copied & pasted both pySerialTransfer.py and CRC.py to the same folder where I'm running the rx and tx files. I also tried removing the "." in .CRC, to no avail.

I'm not sure what's wrong.

ericshear26 avatar Feb 11 '25 18:02 ericshear26

This happened even though I copied & pasted both pySerialTransfer.py and CRC.py to the same folder where I'm running the rx and tx files.

Why would you do this? Did pip-installing not work?

PowerBroker2 avatar Feb 11 '25 23:02 PowerBroker2

My mistake. I was using the files downloaded directly from GitHub. I deleted them and am now using the ones I pip-installed.

After I pip-installed crc and ran rx_data.py again, I got this error message:

File "/Users/Eric/Desktop/Dissertation/Codes & Scripts/Python/rx_data.py", line 3, in from pySerialTransfer.pySerialTransfer import Status ImportError: cannot import name 'Status' from 'pySerialTransfer.pySerialTransfer' (/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pySerialTransfer/pySerialTransfer.py)

I looked for "Status" in the pySerialTransfer.py file in my system and it doesn't have a Status class. But the one on GitHub does. There are many differences between the two versions. Would I have to replace this one with the other?

ericshear26 avatar Feb 12 '25 15:02 ericshear26

The latest version of the main branch wasn't tagged out for some reason. If you look at the examples included in the latest release, they should work with the pip-installed version of the lib.

Sorry for the confusion, I'll probably just tag out the main branch later this evening so that you can use the examples found on the main branch and make things easier.

PowerBroker2 avatar Feb 12 '25 19:02 PowerBroker2

Should be fixed in 2.6.11

PowerBroker2 avatar Feb 13 '25 04:02 PowerBroker2