在运行程序之前,我必须在终端中运行以下代码:
(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”环境变量中找不到programdscsm047.exe
。请在终端/cmd中键入echo %PATH%
以查看路径变量。
您可能可以在C:\DSSAT47\DSCSM047.EXE
下找到可执行文件
如果没有,请阅读here文档。
如果你真的在dscsm047.exe
下找到C:\DSSAT47
。然后你可以在终端运行这个
set PATH="C:\DSSAT47;%PATH%"
python "C:/Users/user pc/PycharmProjects/testProj/auto.py"
关于python - 如何调试“FileNotFoundError:[WinError 2]系统找不到指定的文件”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54995477/