1
votes

I not that good in programming and have a problem using the subprocess() command in Python. My program creates the following string:

wsl ocrmypdf -sr -l deu "\mnt\z\dms\_inbox\Scan 2019-11-27 13.12.33.pdf" "z:\dms\_inbox\OCR_Scan 2019-11-27 13.12.33.pdf"

If I use this command in my Windows 10 DOSbox it is working without issues.

Now I want to start it with the following Python command:

subprocess.run(cmd, shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True).decode()

While cmd contains the above mentioned string.

The system returns something like command wsl not found.

What is wrong?

Update. The error message in wing is: The error message in wing is:

File "D:\DMS\MiniDMS.py", line 73, in subprocess.run(cmd, shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True).decode() File "C:\Python\Lib\subprocess.py", line 512, in run raise CalledProcessError(retcode, process.args,

subprocess.CalledProcessError: Command 'C:\Windows\System32\wsl.exe ocrmypdf -sr -l deu \mnt\z\dms_inbox\Scan 2019-11-27 13.12.33.pdf z:\dms_inbox\OCR_Scan 2019-11-27 13.12.33.pdf' returned non-zero exit status 1.

I think there were some quotes missing in the string. So I changed it to

C:\Windows\System32\wsl.exe ocrmypdf -sr -l deu "\mnt\z\dms\_inbox\Scan 2019-11-27 13.12.33.pdf" "z:\dms\_inbox\OCR_Scan 2019-11-27 13.12.33.pdf"

the error output is now:

Der Befehl "C:\Windows\System32\wsl.exe" ist entweder falsch geschrieben oder konnte nicht gefunden werden. which means that the command wsl.exe could not be found (even if it is there...)

1
Details matter. Include the entire message, not "something like" the error message. - jordanm
always put full error message (starting at word "Traceback") in question (not comment) as text (not screenshot). There are other useful information. - furas
if it can't find it then use \full\path\to\wsl - furas
The error message is in german "something like" means I simply translated it. I'm using the wing IDE in debugging mode and can't find the keyword "traceback". "wsl" is the keyword for "Windows subsystem linux" and is usually used in a DOS box without any path. I'm not sure if it has a path or if it is a command like "dir"... - Dodger

1 Answers

2
votes

The reason for this behaviour: wsl.exe is a 64bit application and therefore located in the real system32 folder. As my python installation is a 32bit application, it always refers to the SysWOW64 folder which does not contain the wsl.exe.

The way to solve it: I simply installed python as 64bit application, now it is working.