美文网首页
解决:gcc: fatal error: cannot exec

解决:gcc: fatal error: cannot exec

作者: no0one | 来源:发表于2023-12-03 11:45 被阅读0次

最近准备试用localGPT这个项目,安装requirements时遇到如下问题:
pip install -r requirements.txt

Building wheels for collected packages: auto-gptq, chroma-hnswlib, sentence-transformers, docx2txt, pypika, langdetect, rouge-score, pycountry, sqlitedict, iopath, antlr4-python3-runtime
  Building wheel for auto-gptq (setup.py) ... done
  Created wheel for auto-gptq: filename=auto_gptq-0.2.2-py3-none-any.whl size=58239 sha256=824f6464200ca2c98416b8de21a686e66a3d7698e270ef4aa85b036a2207839f
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/bf/f6/50/bb6ab784e7824cbf190a1a8205d91e6543287718fb21d5b033
  Building wheel for chroma-hnswlib (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for chroma-hnswlib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [59 lines of output]
      running bdist_wheel
      running build
      running build_ext
      creating tmp
      gcc -pthread -B /home/wangcheng/anaconda3/envs/localGPT/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/wangcheng/anaconda3/envs/localGPT/include -fPIC -O2 -isystem /home/wangcheng/anaconda3/envs/localGPT/include -fPIC -I/home/wangcheng/anaconda3/envs/localGPT/include/python3.10 -c /tmp/tmph1sjo_hm.cpp -o tmp/tmph1sjo_hm.o -std=c++14
      gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
      compilation terminated.
      gcc -pthread -B /home/wangcheng/anaconda3/envs/localGPT/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/wangcheng/anaconda3/envs/localGPT/include -fPIC -O2 -isystem /home/wangcheng/anaconda3/envs/localGPT/include -fPIC -I/home/wangcheng/anaconda3/envs/localGPT/include/python3.10 -c /tmp/tmpkvbaa8g0.cpp -o tmp/tmpkvbaa8g0.o -std=c++11
      gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
      compilation terminated.
      Traceback (most recent call last):
        File "/home/wangcheng/anaconda3/envs/localGPT/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/wangcheng/anaconda3/envs/localGPT/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/wangcheng/anaconda3/envs/localGPT/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 404, in build_wheel
          return self._build_with_temp_dir(
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 389, in _build_with_temp_dir
          self.run_setup()
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 116, in <module>
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 368, in run
          self.run_command("build")
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 131, in run
          self.run_command(cmd_name)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 88, in run
          _build_ext.run(self)
        File "/tmp/pip-build-env-mvv40kku/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
          self.build_extensions()
        File "<string>", line 103, in build_extensions
        File "<string>", line 70, in cpp_flag
      RuntimeError: Unsupported compiler -- at least C++11 support is needed!
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for chroma-hnswlib
  Building wheel for sentence-transformers (setup.py) ... done
  Created wheel for sentence-transformers: filename=sentence_transformers-2.2.2-py3-none-any.whl size=125923 sha256=11723eb10db011310c54652b726a47ec3744d3148fecd3226f22a15a9d67eaa7
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/62/f2/10/1e606fd5f02395388f74e7462910fe851042f97238cbbd902f
  Building wheel for docx2txt (setup.py) ... done
  Created wheel for docx2txt: filename=docx2txt-0.8-py3-none-any.whl size=3959 sha256=c860d692f819e89dc2eb9ba3ff2d84f804ab91dd8cf47633a61db43084a67900
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/22/58/cf/093d0a6c3ecfdfc5f6ddd5524043b88e59a9a199cb02352966
  Building wheel for pypika (pyproject.toml) ... done
  Created wheel for pypika: filename=PyPika-0.48.9-py2.py3-none-any.whl size=53723 sha256=d1e15fd584321e83a09d93d714a11c2b19f842c057845757456b2175ee6da95a
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/e1/26/51/d0bffb3d2fd82256676d7ad3003faea3bd6dddc9577af665f4
  Building wheel for langdetect (setup.py) ... done
  Created wheel for langdetect: filename=langdetect-1.0.9-py3-none-any.whl size=993224 sha256=7904a60efe4960ab68d1808e7245650c36fd7511060d2d78c7c4182355110da4
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/95/03/7d/59ea870c70ce4e5a370638b5462a7711ab78fba2f655d05106
  Building wheel for rouge-score (setup.py) ... done
  Created wheel for rouge-score: filename=rouge_score-0.1.2-py3-none-any.whl size=24932 sha256=2401b47c0ff4431328880b4b3d94248671354a14d329cb373cac4915f71fb760
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/5f/dd/89/461065a73be61a532ff8599a28e9beef17985c9e9c31e541b4
  Building wheel for pycountry (pyproject.toml) ... done
  Created wheel for pycountry: filename=pycountry-22.3.5-py2.py3-none-any.whl size=10681832 sha256=a5d5d78d4666582292d60916c837c87bc07ed62a2f7a4a2a100793886faba826
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/03/57/cc/290c5252ec97a6d78d36479a3c5e5ecc76318afcb241ad9dbe
  Building wheel for sqlitedict (setup.py) ... done
  Created wheel for sqlitedict: filename=sqlitedict-2.1.0-py3-none-any.whl size=16864 sha256=00d5dae9e6c9e275cadaf94de41ce3b409849e5ff915048882b838a1887d2e76
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/79/d6/e7/304e0e6cb2221022c26d8161f7c23cd4f259a9e41e8bbcfabd
  Building wheel for iopath (setup.py) ... done
  Created wheel for iopath: filename=iopath-0.1.10-py3-none-any.whl size=31530 sha256=fc5c6f6767dbc5c119e8b234dd6fd72f20db5aa5bdccf926d9cc4a366fda29de
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/9a/a3/b6/ac0fcd1b4ed5cfeb3db92e6a0e476cfd48ed0df92b91080c1d
  Building wheel for antlr4-python3-runtime (setup.py) ... done
  Created wheel for antlr4-python3-runtime: filename=antlr4_python3_runtime-4.9.3-py3-none-any.whl size=144554 sha256=7aea72af1904e4d3dc0df14fb385e5e0da1761fa361f8dc400268db92bf0d05c
  Stored in directory: /tmp/pip-ephem-wheel-cache-9mqzqu6p/wheels/12/93/dd/1f6a127edc45659556564c5730f6d4e300888f4bca2d4c5a88
Successfully built auto-gptq sentence-transformers docx2txt pypika langdetect rouge-score pycountry sqlitedict iopath antlr4-python3-runtime
Failed to build chroma-hnswlib
ERROR: Could not build wheels for chroma-hnswlib, which is required to install pyproject.toml-based projects

stack overflow上的这个帖子 Compile error: "g++: error trying to exec 'cc1plus': execvp: No such file or directory"解决了我的问题。
主要有两类:

  1. g++未安装
  2. gcc和g++版本不一致

我的情况是第二类,gcc和g++版本不一致,首先检查两者的版本是否一致,如果不一致,修改链接文件。
具体解决办法如下:

This problem can happen if different versions of g++ and gcc are installed.
如果安装了不同版本的 g++ 和 gcc,则可能会出现此问题

g++ --version
gcc --version

If these don't give the result, you probably have multiple versions of gcc installed. You can check by using:
如果这些没有给出结果,您可能安装了多个版本的 gcc。您可以使用以下方法进行检查:

dpkg -l | grep gcc | awk '{print $2}'

Usually, /usr/bin/gcc will be sym-linked to /etc/alternatives/gcc which is again sym-linked to say /usr/bin/gcc-4.6 or /usr/bin/gcc-4.8 (In case you have gcc-4.6, gcc-4.8 installed.)
通常, /usr/bin/gcc 将被符号链接到 /etc/alternatives/gcc ,而 /etc/alternatives/gcc 又被符号链接为 /usr/bin/gcc-4.6 或 /usr/bin/gcc-4.8 (如果你有安装了 gcc-4.6、gcc-4.8。)

By changing this link you can make gcc and g++ run in the same version and this may resolve your issue!
通过更改此链接,您可以使 gcc 和 g++ 在同一版本中运行,这可能会解决您的问题!

相关文章

网友评论

      本文标题:解决:gcc: fatal error: cannot exec

      本文链接:https://www.haomeiwen.com/subject/davkgdtx.html