code_10
code_10

Reputation: 345

FileNotFoundError: [WinError 2] The system cannot find the file specified while running fastapi project using manage-fastapi

I am getting the following error when I try to run my fastapi project

1491, in _execute_child     
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

I am using manage-fastapi as package manager for creating fastapi project find the link for manage-fastapi https://github.com/ycd/manage-fastapi

I am getting this error when I am executing fastapi run

Upvotes: 0

Views: 668

Answers (1)

user459872
user459872

Reputation: 24562

From the traceback it seems like manage-fastapi is trying to execute some external commands. The way to execute external commands in python is using subprocess module. So searching over the manage-fastapi repository finds only two instances of subprocess call. One is,

def validate_project(cls, values: dict):
        try:
            values["username"] = subprocess.check_output(
                ["git", "config", "--get", "user.name"]
            )
            values["email"] = subprocess.check_output(
                ["git", "config", "--get", "user.email"]
            )
        except subprocess.CalledProcessError:
            ...

And the other is

subprocess.call(["uvicorn", f"{app_file}:app", *args])

The former have an except clause, so even if subprocess.check_output raises an exception the except clause will silently bypass it. But the other one does not have any exception mechanism.

So I strongly believe that uvicorn dependency missing in your project, and installing this will most likely resolve the issue.

Upvotes: 2

Related Questions