Running lpr on windows from python

Random832 random832 at fastmail.com
Wed Apr 20 10:09:10 EDT 2016


On Wed, Apr 20, 2016, at 09:57, loial wrote:
> I am trying to run lpr from python 2.7.10 on windows
> 
> However I always get the error
> 'C:/windows/system32/lpr.exe ' is not recognized as an internal or
> external command,
> operable program or batch file.
> 
> Even though typing the same at the  command prompt works OK

It does? This command doesn't exist on my machine. It's not a standard
part of windows.

Just to check though, are you 64-bit windows, and 32 or 64 bit python?
(To find out what kind of windows, go to the system control panel - to
find out if python is 64-bit look at the value of sys.maxsize, it's
2147483647 on 32-bit systems and 9223372036854775807 on 64-bit)

> Any ideas?
> 
> I am using subprocess as follows
> 
> process = subprocess.Popen(commandline, shell=True,
> stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> 
> where command line is
> C:/windows/system32/lpr.exe -S 172.28.84.38 -P RAW C:/john/myfile

If all you want to do is print a text file, see
http://www.robvanderwoude.com/printfiles.php - these commands may not
let you do whatever you're trying to do with that IP address though.



More information about the Python-list mailing list