(Aug-26-2021, 01:28 PM)Joni_Engr Wrote: Hi, I am not able to connect to serial. I get an error "ModuleNotFoundError: No module named 'serial'"
Hi, yes it is installed but I am not able to connect to the serial port.
This message
ModuleNotFoundError
is not a connect problem,it's a install package\module problem.
A quick test in a virtual environment install is
pip install pyserial
.
>>> import serial
>>>
>>> serial.Serial
<class 'serial.serialwin32.Serial'>
# Just to make a ModuleNotFoundError
>>> import serial99
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'serial99'
Connection/port problem give this message,this is a step future and module works.
>>> ser = serial.Serial('/dev/ttyUSB0')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\code\cpu_env\lib\site-packages\serial\serialwin32.py", line 33, in __init__
super(Serial, self).__init__(*args, **kwargs)
File "c:\code\cpu_env\lib\site-packages\serial\serialutil.py", line 244, in __init__
self.open()
File "c:\code\cpu_env\lib\site-packages\serial\serialwin32.py", line 64, in open
raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port '/dev/ttyUSB0': FileNotFoundError(2, 'Systemet finner ikke angitt bane.', None, 3)
could not open port '/dev/ttyUSB0': FileNotFoundError(2, 'Systemet finner ikke angitt bane.', None, 3)