thomkell
thomkell

Reputation: 315

Script with subprocess not working on a other Windows PC

I wrote two different python scripts (python 3.10.4) and it works on my Windows 10 PC, but not on a second one which I have here for testing, also Windows 10.

The problem is subprocess and I have no clue what the problem could be. Any suggestions? The subprocess should convert some latex files in a pdf.

proc = subprocess.Popen(['pdflatex',newFilename])
proc.communicate()`

Console Feedbacks File1&File2:

proc = subprocess.Popen(['pdflatex', newFilename])
File "subprocess.py", line 966, in __init__
File "subprocess.py", line 1435, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified```
proc = subprocess.Popen(['pdflatex',newFilename])
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line
966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line
1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Upvotes: 0

Views: 1290

Answers (1)

sidereal
sidereal

Reputation: 36

Well it doesn't necessarily have to do with the fact that you use different computers or with a subprocess error. The error code is as follows:

FileNotFoundError: [WinError 2] The system cannot find the file specified

On what program are you running Python on your second computer? You should check whether or not your current working directory, the directory in which your Python code is running, is the same directory in which the file is located. You can do a quick check by looking through your documents or by using:

import os

cwd=os.getcwd()
print(cwd)

This lets you see in which directory your Python file is running, now check where the file is located on the computer.

Upvotes: 1

Related Questions