Running lpr on windows from python

Tim Golden mail at timgolden.me.uk
Wed Apr 20 10:08:49 EDT 2016


On 20/04/2016 14: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
> 
> 
> 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
> 

Ummm.. Do you actually have a program called lpr.exe in that location?
It's not usual on Windows. (I rather assume you do since you give the
full path, but still...)

IOW, what happens if you type:

  dir C:\windows\system32\lpr.exe

at a command promopt?

Also: are you on a 64-bit system? If so, c:\windows\system32 probably
isn't where you think it is. cf, for example:

  https://mail.python.org/pipermail/python-win32/2012-March/012121.html

TJG



More information about the Python-list mailing list