首页 > 解决方案 > “如何在安装“SudachiPy”python 包时修复'错误:命令'gcc'失败,退出状态为 1'?

问题描述

我正在构建日语 NLP 情绪分析,为了标记日语句子,我们有一个名为“SudachiPy”的包。我尝试安装它,但在安装包时出现错误。我在 MAC Book pro 中使用 anaconda。

我通过安装以下库来调试错误,尝试了堆栈溢出中提到的所有步骤。

pip3 install python3-dev

我还尝试从 AWS 启动“Ubuntu”实例并尝试安装“SudachiPy”,但仍然遇到相同的错误。

pip3 install SudachiPy


Building wheels for collected packages: dartsclone
  Building wheel for dartsclone (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lf/4754h1x94x39xfw_q6c8_ryc0000gn/T/pip-install-st3sqcmm/dartsclone/setup.py'"'"'; __file__='"'"'/private/var/folders/lf/4754h1x94x39xfw_q6c8_ryc0000gn/T/pip-install-st3sqcmm/dartsclone/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/lf/4754h1x94x39xfw_q6c8_ryc0000gn/T/pip-wheel-x8k1ryul --python-tag cp36
       cwd: /private/var/folders/lf/4754h1x94x39xfw_q6c8_ryc0000gn/T/pip-install-st3sqcmm/dartsclone/
  Complete output (25 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.7-x86_64-3.6
  creating build/lib.macosx-10.7-x86_64-3.6/dartsclone
  copying dartsclone/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/dartsclone
  running build_ext
  cythoning dartsclone/_dartsclone.pyx to dartsclone/_dartsclone.cpp
  /anaconda3/lib/python3.6/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/lf/4754h1x94x39xfw_q6c8_ryc0000gn/T/pip-install-st3sqcmm/dartsclone/dartsclone/_dartsclone.pxd
    tree = Parsing.p_module(s, pxd, full_module_name)
  warning: dartsclone/_dartsclone.pyx:119:49: local variable 'result' referenced before assignment
  warning: dartsclone/_dartsclone.pyx:120:15: local variable 'result' referenced before assignment
  building 'dartsclone._dartsclone' extension
  creating build/temp.macosx-10.7-x86_64-3.6
  creating build/temp.macosx-10.7-x86_64-3.6/dartsclone
  creating build/temp.macosx-10.7-x86_64-3.6/csrc
  creating build/temp.macosx-10.7-x86_64-3.6/csrc/src
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -I./csrc/include -I/anaconda3/include/python3.6m -c dartsclone/_dartsclone.cpp -o build/temp.macosx-10.7-x86_64-3.6/dartsclone/_dartsclone.o
  warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
  dartsclone/_dartsclone.cpp:610:10: fatal error: 'ios' file not found


    #include "ios"
               ^~~~~
      1 warning and 1 error generated.
      error: command 'gcc' failed with exit status 1
      ----------------------------------------
      ERROR: Failed building wheel for dartsclone

标签: python-3.6

解决方案


之前需要安装一些deps,类似于Linux build-essential

xcode-select install

此外,您可能需要通过设置此环境来指定正确的编译器。多变的:

CFLAGS='-stdlib=libc++'


推荐阅读