Comments (6)
Hi @rodhoff !
Well, I think you are not using our python-escpos library but some other escpos library written in python.
Anyway, your issue looks like a permission problem.
Did you try to run your script as an administrator?
Sadly, I can't help you much more.
from python-escpos.
Hi @belono !
Sorry for the mistake, I'm trying several approaches to understand why it's not working. I have tried to run this sample code for the python-escpos even though:
from escpos.printer import Serial
p = Serial(devfile='COM2',
baudrate=9600,
bytesize=8,
parity='N',
stopbits=1,
timeout=1.00,
dsrdtr=True)
p.text("Hello World\n")
p.qr("You can readme from your smartphone")
p.cut()
And I got the same error message, even running from an elevated powershell:
(c:\Users\rodri\dev\pycoupon\v-fatura) C:\Users\rodri\dev\pycoupon [main +3 ~1 -0 !]> python serial-test-3.py
Traceback (most recent call last):
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\printer\serial.py", line 136, in open
self.device: Optional[serial.Serial] = serial.Serial(
^^^^^^^^^^^^^^
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\serial\serialwin32.py", line 33, in __init__
super(Serial, self).__init__(*args, **kwargs)
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\serial\serialutil.py", line 244, in __init__
self.open()
File "c:\Users\rodri\dev\pycoupon\v-fatura\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 'COM2': PermissionError(13, 'Acesso negado.', None, 5)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\rodri\dev\pycoupon\serial-test-3.py", line 10, in <module>
p.text("Hello World\n")
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\escpos.py", line 863, in text
self.magic.write(str(txt))
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\magicencode.py", line 282, in write
self.write_with_encoding(encoding, to_write)
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\magicencode.py", line 304, in write_with_encoding
self.driver._raw(
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\printer\serial.py", line 163, in _raw
assert self.device
^^^^^^^^^^^
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\escpos.py", line 146, in device
self.open()
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\printer\serial.py", line 50, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\rodri\dev\pycoupon\v-fatura\Lib\site-packages\escpos\printer\serial.py", line 150, in open
raise DeviceNotFoundError(
escpos.exceptions.DeviceNotFoundError: Device not found (Unable to open serial printer on COM2:
could not open port 'COM2': PermissionError(13, 'Access denied.', None, 5))
I'm using VSPE to emulate the COM2 - COM5 pair and the Bematech printer emulator.
from python-escpos.
As I'm using VSPE, and emulated a pair of com ports (COM2<=>COM5) I believe it will use COM2 to emulate the printer, and would listen for requests from COM5... When I changed COM2 to COM5, I don't get any error - but don't get anything printed as well...
from python-escpos.
It seems that Bematech doesn't support ESC/POS commands, so you can't print with this library on a Bematech printer.
Did you choose a Bematech emulator because you have to support a printer of that specific model?
EDIT:
Sorry, seems that I was wrong. --> See chapter 4
Some Bematech printers have dual command set support ESCBema/ESCPOS, so you could print with the help of python-escpos.
from python-escpos.
Thanks @belono !
No specific reason for using Bematech, it's only that I've found it first. Is there any other reasonable one which you know I could use?
from python-escpos.
Depending on your needs, there are some tools more or less related to our library that you can use to check your code is working.
-
If you just want to check you are sending well-formatted commands to python-escpos you simply can make use of our
Dummy
printer connector and check the raw output it would be sent to your printer.
Documentation of the Dummy printer connector -
A more similar approach to a virtual printer where you can use a real connection to a 'virtual network device' and see some simple output is the escpos-printer-simulator that is quite straightforward to use. Just download the binary and run it in java, it starts a server at a port that listens to escpos commands and renders to a window the raw output you send using our
Network
printer connector. -
If you would like to see some final output with limited support to images and some complex layout then esc2html would be your choice. It could render an html representation of the
Dummy.output()
. To tell the truth I've never used this tool but, if I'm not wrong, just save the output to a binary file and open it up with esc2html to get an html file that you can then open up in a web browser.
Surely, there are more and maybe better tools to simulate an escpos printer but these are the ones I know.
More suggestions are welcome from my side.
from python-escpos.
Related Issues (20)
- Text size not working (width and height) HOT 11
- Image printing prints only garbage HOT 29
- Barcode not printed HOT 4
- Introduce IntEnum or similar for printer states
- Usb printer not working on web Application HOT 2
- Printer not found on web application HOT 1
- Font switching not working. HOT 3
- is_online() fails with raise NotImplementedError()
- Full cut not working on Epson TM-T20III HOT 2
- 'usb timeout error' when used on a raspberry pi 3 with a cheap POS-58 thermal printer HOT 5
- ImportError: cannot import name 'DeviceNotFoundError' from 'escpos.exceptions' HOT 2
- usb.core.USBError: [Errno 5] Input/Output Error` HOT 1
- EPSON TM-m30III randomly fails to print images HOT 1
- Arabic Text not printing correctly HOT 2
- Tabbed text HOT 8
- windows Invalid endpoint address HOT 1
- How to print big5 charcode HOT 1
- CLI not working for CupsPrinter, LP and Win32Raw connectors
- Print to a bluetooth device via rfcomm and printer.File() HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-escpos.