在MacOS中安装正则表达式时出现编译错误

2024-04-20 14:21:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在macos catalina上安装Regex,但我遇到了这个错误,我该如何继续?我试图更新pippip3pipwinxcode,但两者都返回相同的错误,安装NLTK时也会发生相同的情况

我能够在ubuntu虚拟机上安装,并且只在MacOs上安装了所有东西,REGEX和NLTK,我继续下面的错误:

pip3 install regex
Collecting regex
  Using cached regex-2020.6.8.tar.gz (690 kB)
Building wheels for collected packages: regex
  Building wheel for regex (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/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/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-wheel-j6dr4ocd
       cwd: /private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/
  Complete output (17 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.14-x86_64-3.7
  creating build/lib.macosx-10.14-x86_64-3.7/regex
  copying regex_3/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/regex
  copying regex_3/regex.py -> build/lib.macosx-10.14-x86_64-3.7/regex
  copying regex_3/_regex_core.py -> build/lib.macosx-10.14-x86_64-3.7/regex
  copying regex_3/test_regex.py -> build/lib.macosx-10.14-x86_64-3.7/regex
  running build_ext
  building 'regex._regex' extension
  creating build/temp.macosx-10.14-x86_64-3.7
  creating build/temp.macosx-10.14-x86_64-3.7/regex_3
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c regex_3/_regex.c -o build/temp.macosx-10.14-x86_64-3.7/regex_3/_regex.o
  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for regex
  Running setup.py clean for regex
Failed to build regex
Installing collected packages: regex
    Running setup.py install for regex ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-record-olfcxoeu/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/regex
         cwd: /private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/
    Complete output (17 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-x86_64-3.7
    creating build/lib.macosx-10.14-x86_64-3.7/regex
    copying regex_3/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/regex
    copying regex_3/regex.py -> build/lib.macosx-10.14-x86_64-3.7/regex
    copying regex_3/_regex_core.py -> build/lib.macosx-10.14-x86_64-3.7/regex
    copying regex_3/test_regex.py -> build/lib.macosx-10.14-x86_64-3.7/regex
    running build_ext
    building 'regex._regex' extension
    creating build/temp.macosx-10.14-x86_64-3.7
    creating build/temp.macosx-10.14-x86_64-3.7/regex_3
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c regex_3/_regex.c -o build/temp.macosx-10.14-x86_64-3.7/regex_3/_regex.o
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-install-fzw0lg0t/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6h/wf23bbbj7t7dwhyzz0cjw3_r0000gn/T/pip-record-olfcxoeu/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/regex Check the logs for full command output.**strong text**

Tags: installpippybuildincludevarlibusr
1条回答
网友
1楼 · 发布于 2024-04-20 14:21:56

我不是mac超级用户,但你可以试试这个,看看它是否有效

xcode-select install

如果它说已经安装了,请尝试:

xcode-select reset

我认为这可能是问题的原因是正在发生的xcrun错误的原因

相关问题 更多 >