报错subprocess.CalledProcessError: Command ‘[‘which‘, ‘g++‘]‘ returned non-zero exit status 1.

在安装torch的时候,torch安装成功,但是torch-cluster、torch-sparse等报错

Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-56zzyn27/torch-sparse/setup.py", line 46, in <module>
      packages=find_packages(),
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 290, in run
      self.run_command('build')
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
      _build_ext.run(self)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/command/build_ext.py", line 339, in run
      self.build_extensions()
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 232, in build_extensions
      self._check_abi()
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 370, in _check_abi
      check_compiler_abi_compatibility(compiler)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 162, in check_compiler_abi_compatibility
      if not check_compiler_ok_for_platform(compiler):
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 138, in check_compiler_ok_for_platform
      which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/subprocess.py", line 356, in check_output
      **kwargs).stdout
    File "/home/aha/anaconda3/envs/geo/lib/python3.6/subprocess.py", line 438, in run
      output=stdout, stderr=stderr)
  subprocess.CalledProcessError: Command '['which', 'g++']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for torch-sparse

尝试了各种各样的方法,这个错误找了好多天,担心环境不匹配问题,python、conda都是卸了又重新安装,终于!!!找到了解决办法

Command ‘[‘which’, ‘g++’]’

哈哈哈哈,我也不知道自己为什么会聚焦在这儿,真的是每一个单词可能涉及到的错误我都去找了,终于!!!
g++是个啥我也不知道,于是乎嗖嗖嗖,看到了这个:
https://github.com/facebookresearch/detectron2/issues/667
上面说可能是没有安装g++
我也不知道我的ubuntu里面有没有
于是就安装吧:

sudo apt-get install build-essential

参考:

https://blog.csdn.net/klarclm/article/details/8550931

ok,安装完g++后再执行pip安装,解决问题!!!(仰天长啸!!!)
希望能够帮助到你们,我真的是弄了好久好久!!!

  • 45
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值