Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python : FileNotFoundError [WinError 2] The system cannot find the file specified , subprocess.py:1582

Details error message:-

 FileNotFoundError

  [WinError 2] The system cannot find the file specified

  at ~\AppData\Local\Programs\Python\Python39\lib\subprocess.py:1582 in _execute_child
      1578│             sys.audit("subprocess.Popen", executable, args, cwd, env)
      1579│ 
      1580│             # Start the process
      1581│             try:
    → 1582│                 hp, ht, pid, tid = _winapi.CreateProcess(
      1583│                     executable,
      1584│                     args,
      1585│                     # no special security
      1586│                     None,
make: *** [makefile:14: format] Error 1

We have something similar issue listed here: https://bugs.python.org/issue17023

The file is there, the path is fine too. But why am I getting this error as the file is there at the specified location?

I`m getting this error while running formatter linters.

like image 200
Lakshay Rohilla Avatar asked Nov 28 '25 19:11

Lakshay Rohilla


1 Answers

You can just set shell = True and pass it to the subprocess class you are using. Modifying the library file will cause compatibility problems later on with codes from other programmers. To get some insight into why we need to set this variable, take a look at the documentation: "args is required for all calls and should be a string, or a sequence of program arguments. Providing a sequence of arguments is generally preferred, as it allows the module to take care of any required escaping and quoting of arguments (e.g. to permit spaces in file names). If passing a single string, either shell must be True (see below) or else the string must simply name the program to be executed without specifying any arguments."

like image 196
Iman Dadras Avatar answered Dec 01 '25 08:12

Iman Dadras