Python Forum
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with pySerial
#2
(Apr-12-2017, 05:56 AM)oz1sej Wrote: "import serial" at the start of the program triggers no errors despite the fact that the file serial.py is not in the directory. Shouldn't it?

That is ok, the location where module got installed is (considering your observation) in Python's search path, and that's all that is needed.

'/dev/ttyUSB0': FileNotFoundError suggests there is no 'ttyUSB0' device in the /dev/ directory, can you verify that?
I assume you are using this resource. It is generic, so you may need to modify things here and there (e.g. change port/device names, to avoid issues like you've encountered).

Also, to avoid unpleasant surprises in future... when you run code that opens serial port, make sure to close it afterwards with ser.close()  or you will get errors due to port already open next time try to open it.
Or you can use with serial.Serial... which will close it for you after its work is done.
Reply


Messages In This Thread
I need help with pySerial - by oz1sej - Apr-12-2017, 05:56 AM
RE: I need help with pySerial - by j.crater - Apr-12-2017, 06:12 AM
RE: I need help with pySerial - by buran - Apr-12-2017, 06:13 AM
RE: I need help with pySerial - by oz1sej - Apr-12-2017, 07:14 AM
RE: I need help with pySerial - by j.crater - Apr-12-2017, 07:21 AM
RE: I need help with pySerial - by oz1sej - Apr-12-2017, 07:41 AM
RE: I need help with pySerial - by j.crater - Apr-12-2017, 07:45 AM
RE: I need help with pySerial - by oz1sej - Apr-12-2017, 09:53 AM
RE: I need help with pySerial - by j.crater - Apr-13-2017, 05:20 AM
RE: I need help with pySerial - by Larz60+ - Apr-13-2017, 06:12 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020