subprocess.CalledProcessError:命令'['which','c++']'返回非零退出状态1

Bru*_*ywj 5 python linux pycharm torch ubuntu-20.04

请帮助我,困惑了近两天。

File "/data/ywj/Anaconda3/envs/torch/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 252, in check_compiler_abi_compatibility
if not check_compiler_ok_for_platform(compiler):
File "/data/ywj/Anaconda3/envs/torch/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 212, in check_compiler_ok_for_platform
which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
File "/data/ywj/Anaconda3/envs/torch/lib/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/data/ywj/Anaconda3/envs/torch/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1.
Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

我已经在/data/ywj/gcc73/gcc73中安装了gcc/g++7.3.0(非root)

我在服务器上运行该程序没有出现此错误,但是当我远程连接到服务器并在 Pycharm 中运行该程序时,出现此错误。

one*_*one 1

我猜你正在构建或安装一些软件包。

首先,尝试通过以下方式获取 g++ 的版本:g++ --version

Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Run Code Online (Sandbox Code Playgroud)

然后,为您的构建命令添加前缀CXX=g++-9 CC=gcc-9 LD=g++-9,例如:

CXX=g++-9 CC=gcc-9 LD=g++-9 pip install xxxx
Run Code Online (Sandbox Code Playgroud)

请注意,这9意味着您的 g++ 版本。