python3 用pip3命令安装scrapy的时候,会在安装twisted这一步发生错误(直接安装Twisted也是同样错误),摘录了一小段,如下

  copying src/twisted/internet/test/_awaittests.py.3only -> build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test
    copying src/twisted/internet/test/_yieldfromtests.py.3only -> build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test
    creating build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/chain.pem -> build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/not-a-certificate -> build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/thing1.pem -> build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/thing2-duplicate.pem -> build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/thing2.pem -> build/lib.macosx-10.9-x86_64-3.7/twisted/internet/test/fake_CAs
    running build_ext
    building 'twisted.test.raiser' extension
    creating build/temp.macosx-10.9-x86_64-3.7
    creating build/temp.macosx-10.9-x86_64-3.7/src
    creating build/temp.macosx-10.9-x86_64-3.7/src/twisted
    creating build/temp.macosx-10.9-x86_64-3.7/src/twisted/test
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/twisted/test/raiser.c -o build/temp.macosx-10.9-x86_64-3.7/src/twisted/test/raiser.o
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/jt/97hxf7_55yj692hkv36855kh0000gn/T/pip-install-e23rfh99/Twisted/setup.py'"'"'; __file__='"'"'/private/var/folders/jt/97hxf7_55yj692hkv36855kh0000gn/T/pip-install-e23rfh99/Twisted/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/jt/97hxf7_55yj692hkv36855kh0000gn/T/pip-record-uwca1vvj/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

分析问题:我踩了很多坑,从版本匹配或者其他方向查找解决方案,都没找到,直接说真正返现问题在哪里,注意看日志有一段内容:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  error: command 'gcc' failed with exit status 1

这个是由于macOS升级mojave 10.14造成的

解决方案:

    在终端执行  xcode-select --install  命令

    然后,重新安装scrapy,问题解决

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐