I want to use pyserial to read data from a serial device with python but I seem to fail at the most basic example.
I installed python with 'brew install python3', installed pyserial as said in the documentation 'python3 -m pip install pyserial' and took the following from the pyserial docs and changed the device:
import serial
ser = serial.Serial('/dev/tty.usbserial-130') print(ser.name) ser.close()
I ran it with 'sudo python3 serial.py' and got an error:
Traceback (most recent call last): File "/Users/x/serial.py", line 1, in import serial File "/Users/x/serial.py", line 3, in ser = serial.Serial('/dev/tty.usbserial-130') ^^^^^^^^^^^^^ AttributeError: partially initialized module 'serial' has no attribute 'Serial' (most likely due to a circular import). Did you mean: 'serial'?
It says the I might have a typo but with serial.serial instead of serial.Serial I just get another error and I cant imagine that their examples are that faulty. I guess its a problem with the python environment?