pjialin/py12306

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Closed this issue · 1 comments

系统 Ubuntu 20.04.1 LTS ,GCC 版本 (Ubuntu 9.3.0-10ubuntu2) 9.3.0 ,pip3 版本 pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8) ,Python 版本 3.8.2 。

执行指令 sudo pip3 install -r requirements.txt 总是报错,尝试过安装各种依赖,还是不行,具体表现是在这里卡很久:

Collecting pyppeteer>=0.0.14
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5d/4b/3c2aabdd1b91fa52aa9de6cde33b488b0592b4d48efb0ad9efbf71c49f5b/pyppeteer-0.2.2-py3-none-any.whl (145 kB)
     |████████████████████████████████| 145 kB 39 kB/s
Building wheels for collected packages: lxml
  Building wheel for lxml (setup.py) ... -

大概等一个多小时后就会报错:

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-x86_64-3.8/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
  copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-3.8/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
  running build_ext
  building 'lxml.etree' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  creating build/temp.linux-x86_64-3.8/src/lxml
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/include/python3.8 -c src/lxml/etree.c -o build/temp.linux-x86_64-3.8/src/lxml/etree.o -w
  x86_64-linux-gnu-gcc: fatal error: Killed signal terminated program cc1
  compilation terminated.
  Compile failed: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  creating tmp
  cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInit4x0_r7he.c -o tmp/xmlXPathInit4x0_r7he.o
  cc tmp/xmlXPathInit4x0_r7he.o -lxml2 -o a.out
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for lxml
  Running setup.py clean for lxml
Failed to build lxml
ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.
ERROR: pyppeteer 0.2.2 has requirement pyee<8.0.0,>=7.0.1, but you'll have pyee 5.0.0 which is incompatible.
ERROR: pyppeteer 0.2.2 has requirement tqdm<5.0.0,>=4.42.1, but you'll have tqdm 4.28.1 which is incompatible.
ERROR: pyppeteer 0.2.2 has requirement urllib3<2.0.0,>=1.25.8, but you'll have urllib3 1.24.2 which is incompatible.
ERROR: pyppeteer 0.2.2 has requirement websockets<9.0,>=8.1, but you'll have websockets 7.0 which is incompatible.
Installing collected packages: lxml, parse, pyee, websockets, tqdm, urllib3, pyppeteer-box, pyquery, redis, requests, pyppeteer, six, w3lib, requests-html, DingtalkChatbot, lightpush
    Running setup.py install for lxml ... -

请问我是依赖导致报错、gcc 版本不符还是其他问题?

等了几个小时等来了最后的错误输出:

    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-3.8/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    creating build/temp.linux-x86_64-3.8/src/lxml
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/include/python3.8 -c src/lxml/etree.c -o build/temp.linux-x86_64-3.8/src/lxml/etree.o -w
    x86_64-linux-gnu-gcc: fatal error: Killed signal terminated program cc1
    compilation terminated.
    Compile failed: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitdx98ycpm.c -o tmp/xmlXPathInitdx98ycpm.o
    cc tmp/xmlXPathInitdx98ycpm.o -lxml2 -o a.out
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m4s47zts/lxml/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m4s47zts/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-jjvespn0/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/lxml Check the logs for full command output.

关于 lxml 我已经用「sudo apt install python3-lxml」更新了。