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

5

请帮我,我已经困惑了将近两天。

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

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

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


1
好的,/data/ywj/gcc73/gcc73/bin 是否在 PATH 中?这是 which 用来查找编译器的。 - AKX
我在运行/调试配置中设置了如下内容: 路径1:/data/ywj/Anaconda3/envs/torch/bin 路径2:/data/ywj/gcc73/gcc73/bin 第一个路径是为了帮助找到Ninja,我不知道这两个路径是否可以同时工作。 - Bruce-ywj
不,PATH2没有被任何东西读取。在UNIX系统上,你使用冒号来分隔路径条目:PATH = /data/ywj/Anaconda3/envs/torch/bin:/data/ywj/gcc73/gcc73/bin - AKX
它可以工作,谢谢!!! 但是...又出现了另一个错误: gcc: 尝试执行 'as' 时出错:execvp: 没有这个文件或目录 ninja: 构建停止:子命令失败。 拜托... - Bruce-ywj
再次感谢!!!问题已完全解决。 - Bruce-ywj
1个回答

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.


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

请注意,9代表您的g++版本。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接