Home > Mobile >  Python : FileNotFoundError [WinError 2] The system cannot find the file specified , subprocess.py:15
Python : FileNotFoundError [WinError 2] The system cannot find the file specified , subprocess.py:15

Time:08-04

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.

CodePudding user response:

To solve this error:- We have to modify the subprocess.py in your environment.

First of all, you have to locate this file and then edit it. In my PC it location is - C:\Users\User\AppData\Local\Programs\Python\Python39\Lib.

In this piece of code:-

def __init__(self, args, bufsize=-1, executable=None,
             stdin=None, stdout=None, stderr=None,
             preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS,
             shell=True, cwd=None, env=None, universal_newlines=False,
             startupinfo=None, creationflags=0,
             restore_signals=True, start_new_session=False,
             pass_fds=(), *, encoding=None, errors=None):

You have to change the value of shell.
Change shell=False to shell = True.

This solution worked for me, I hope it`ll work for you too.

Thank you.

Found helpful, Do upvote !!

  • Related