How to write to printer in Windows?

Randall Hopper aa8vb at
Wed Apr 19 06:47:29 EDT 2000

Albert Wagner:
 |How can I write(aLine) to a printer in Windows?  I tried this:
 |from win32pipe import popen
 |self.printer = popen('lpt1' 'w')
 |but get a general protection fault.  Any help will be greatly

I see you have a pointer to the win32 printer modules in another reply.

The problem with your above code may be something simple though.  From my
DOS days, I seem to recall that 'lpt1:' was the correct name for the
printer device.  lpt1 may be trying to write to a file in a directory for
which you don't have permission.

In a DOS box, try 'copy c:\config.sys lpt1:'.  That'll make sure you're
printer is attached to that device.  If so, you should be able to run your
Python program there with (I would think) the same results.

Randall Hopper
aa8vb at

More information about the Python-list mailing list