在运行程序之前,我必须在终端中运行此代码,如下所示:
(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
由于我是本编程领域的新手,请您更清楚,具体地说明调试此错误的过程。
答案 0 :(得分:0)
此错误消息表明在您的“ PATH”环境变量中找不到程序dscsm047.exe
。请在终端机/ cmd中键入echo %PATH%
,以查看PATH变量。
您可能可以在C:\DSSAT47\DSCSM047.EXE
下找到可执行文件
如果没有,请阅读文档here。
如果您实际上在dscsm047.exe
下找到C:\DSSAT47
。然后您可以在终端中运行它
set PATH="C:\DSSAT47;%PATH%"
python "C:/Users/user pc/PycharmProjects/testProj/auto.py"