Python subprocess.Popen() error (No such file or directory)

This error is easily misunderstood. Most people think that the command is executed, but the command cannot find the file or directory corresponding to the parameter. In fact, there is another meaning, that is, the command cannot be found, and the command cannot be found, and an error that there is no such file or directory will be reported.

Why can't I find this command?

1. The format is wrong, and the string cannot be directly passed in. If the string is passed in directly, you need to set shell=True. This method is not recommended and has security risks.

2. For the configuration of environment variables, the path is not configured correctly, the bin cannot be found, and a subprocess is created. Because the configuration script of /etc/profile is not executed, the environment variable does not have this path, so the general script execution is written like this. The full path /usr/bin/python, to avoid the command python cannot be found.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325342688&siteId=291194637