Closed mattpackwood closed 2 years ago
I'm getting the same error
I was getting the same error. The error comes from the function printer.printImage
needing a filename (string) not an image file (see here). Changing line 101 in main.py
to:
# Print greeting image
printer.printImage('gfx/hello.png', True)
printer.feed(3)
GPIO.output(ledPin, GPIO.LOW)
should get past this hurdle, though there might be other problems lurking (I haven't tried running the full project or main.py
).
Note that the other call to printImage
in main.py
(line 43) will also need to be changed. Presumably the sudoku-gfx.py
file has similar errors in it as well. I'm giving up on chasing all the bugs but I would bet every script in this project that tried to print a PNG file will now stop working.
I would guess that someone introduced breaking changes to the and this is what broke all the scripts in this project. From a cursory look, it seems like the breaking change was here by @galacticfan on May 20, 2020.
Abetusk, I don't think this will work because there are other calls to that function requiring the Image.new. We had to change Adafruit_Thermal.py to get this to work correctly.
Unfortunately, we are new to GitHub and still trying to figure out how to propose our changes :).
Just added a pull request labeled "Add files via upload" with our fixed code.
Merged. Thank you muchly!
@CodeDelux
I tried runningpython3 main.py
and I get:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyS0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 22, in <module>
from datetime import date
File "/home/pi/Python-Thermal-Printer/datetime.py", line 16, in <module>
printer = Adafruit_Thermal("/dev/ttyS0", 19200, timeout=5)
File "/home/pi/Python-Thermal-Printer/Adafruit_Thermal.py", line 84, in __init__
Serial.__init__(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 240, in __init__
self.open()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyS0: [Errno 2] No such file or directory: '/dev/ttyS0
```'
Crazy question, is it trying to use Serial (I am using a USB printer)?
@mattpackwood
This is most likely a separate error from the initial error that was reported in this issue, so might be worth creating it's own issue.
I will say that the /dev/ttyS0
is only referenced in datetime.py
in this repo, so I'm confused as to why this is even being called. I'm not up on the intricacies of Python and how it manages its libraries, but one simple thing to try is to rename the file datetime.py
in the repo as something else (test_datetime_example.py
for example) and then try to see if that solves the problem.
Note that the datetime.py
is being called from the from datetime import date
line in main.py
. I would be shocked if this were the intent as datetime
is a common Python library and date
is not a method provided in the local datetime.py
. I suspect Python is trying to load the local file rather than the standard library. If so, this probably should be a separate bug report to tell the maintainer to rename the local datetime.py
to something that won't conflict with the Python library (like test_datetime_example.py
, for example).
We only use the built in python datetime and we don’t have a local version. So, I think @abetusk is right and you should rename it.
OK, I think that is "all set", I agree there is something "up" with datetime.py
I don't know how to put in a pull request to "delete a file" so I will put in a new issue,
Hi, I am getting the following...
Matt