命令'x86_64-linux-gnu-gcc'以退出状态1失败

msm*_*azh 23 python linux gcc ubuntu-16.04

我试图安装"学术"包,但我一直收到这个错误:

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o
build/temp.linux-x86_64-2.7/_openssl.c:434:30: fatal error: openssl/opensslv.h: No such file or directory
compilation terminated.

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


Command "/usr/bin/python -u -c "import setuptools,tokenize;__file__='/tmp/pip-build-0OXGEx/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-EdgZGB-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-0OXGEx/cryptography/
Run Code Online (Sandbox Code Playgroud)

已经尝试过以下帖子中的解决方案,但它没有用:

pip install lxml错误

小智 60

我有同样的问题.这个帮助了我:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Run Code Online (Sandbox Code Playgroud)

如果你使用python3,尝试替换python-devpython3-dev

  • 关于“python3-dev”的一个小评论对我很有帮助。谢谢你! (3认同)
  • 仅供参考:我有_exact_相同的问题并且安装`libssl-dev`本身足以解决这个问题.从`apt`获取`python-dev`通常是个好主意.*那说:*如果您使用的是Anaconda或其他一些python-environment-engine,请注意不要通过安装python-dev来破坏你的$ PATH. (2认同)

vpa*_*pap 9

在新创建的python 3.6虚拟环境中并尝试运行我setup.py的模块,以下命令解决了错误,

sudo apt-get install python3.6-dev

对我来说,错误是,

... Python.h: No such file or directory
18 | #include "Python.h"
  |          ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

其余的软件包build-essential libssl-dev libffi-dev已经是上次安装的。


小智 5

安装 lib32ncurses5-dev:

sudo apt-get install lib32ncurses5-dev
Run Code Online (Sandbox Code Playgroud)