在运行程序之前,我必须在终端中运行这段代码,如下所示:
(venv) C:\Users\user pc\PycharmProjects\testProj>pip install -U pip --user
Requirement already up-to-date: pip in c:\users\user pc\pycharmprojects\testproj\venv\lib\site-packages (19.0.3)
(venv) C:\Users\user pc\PycharmProjects\testProj>pip install psycopg2 --user
Requirement already satisfied: psycopg2 in c:\users\user pc\pycharmprojects\testproj\venv\lib\site-packages (2.7.7)
因此,pip 已安装。 只有在运行它之后,我必须运行我的程序,其中发生以下错误:
"C:\Users\user pc\PycharmProjects\testProj\venv\Scripts\python.exe" "C:/Users/user pc/PycharmProjects/testProj/auto.py"
The unique id is 1
Traceback (most recent call last):
File "C:/Users/user pc/PycharmProjects/testProj/auto.py", line 381, in <module>
p = subprocess.Popen(["dscsm047.exe"], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
File "C:\Users\user pc\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\user pc\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Process finished with exit code 1
由于我是这个编程领域的新手,能否请您更清楚和具体地说明调试此错误的过程。
最佳答案
此错误消息表示在您的“PATH”环境变量中找不到程序 dscsm047.exe
。请在终端/cmd 中键入 echo %PATH%
以查看 PATH 变量。
您可能可以在 C:\DSSAT47\DSCSM047.EXE
下找到可执行文件
如果没有,请阅读文档 here .
如果你真的在C:\DSSAT47
下找到了dscsm047.exe
。然后你可以在终端中运行它
set PATH="C:\DSSAT47;%PATH%"
python "C:/Users/user pc/PycharmProjects/testProj/auto.py"
关于python - 如何调试 "FileNotFoundError: [WinError 2] The system cannot find the file specified"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54995477/