Linux使用python命令失败,python - 安装脚本退出并显示错误:命令'x86_64-linux-gnu-gcc'失败,退出状态为1...

python - 安装脚本退出并显示错误:命令'x86_64-linux-gnu-gcc'失败,退出状态为1

当我尝试安装odoo-server时,出现以下错误:

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

谁能帮我解决这个问题?

26个解决方案

216 votes

Python.h只是一个头文件。 它由gcc用于构建应用程序。 您需要安装一个名为python-dev的软件包。 该软件包包括头文件,静态库和用于构建Python模块的开发工具,扩展Python解释器或在应用程序中嵌入Python。

输入:

$ sudo apt-get install python-dev

要么

# apt-get install python-dev

见[http://www.cyberciti.biz/faq/debian-ubuntu-linux-python-h-file-not-found-error-solution/]

Fred answered 2019-02-14T16:10:38Z

161 votes

尝试安装这些包。

sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev libssl-dev

sudo easy_install greenlet

sudo easy_install gevent

Madura Dissanayake answered 2019-02-14T16:11:03Z

124 votes

我在大学里遇到了同样的问题,为我最后一年的主要项目安装了Linux Mint,下面的第三个解决方案适合我。

遇到此错误时请注意错误之前它可能说您缺少包或头文件,您应该找到并安装它们并验证它是否有效。 (例如ssl - > libssl)

对于Python 2.x使用:

$ sudo apt-get install python-dev

对于Python 2.7使用:

$ sudo apt-get install libffi-dev

对于Python 3.x使用:

$ sudo apt-get install python3-dev

对于Python 3.4使用:

$ sudo apt-get install python3.4-dev

对于Python 3.5使用:

$ sudo apt-get install python3.5-dev

对于Python 3.6使用:

$ sudo apt-get install python3.6-dev

Paulie answered 2019-02-14T16:12:19Z

87 votes

您需要安装这些包:

sudo apt-get install libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev

WaKo answered 2019-02-14T16:12:44Z

60 votes

$ sudo apt-get install gcc

$ sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi

或者尝试这个:

$ sudo apt-get install libxml2-dev libxslt1-dev

the-run answered 2019-02-14T16:13:08Z

32 votes

在我的情况下,它缺少包libffi-dev。

什么有效:

sudo apt-get install libffi-dev

nikhil komawar answered 2019-02-14T16:13:35Z

31 votes

对于Python 3.4使用:

sudo apt-get install python3.4-dev

对于Ubuntu / Mint上的Python 3.5,请使用:

sudo apt-get install python3.5-dev

对于Python 3.6使用(感谢Or Duan):

sudo apt-get install python3.6-dev

kame answered 2019-02-14T16:14:10Z

30 votes

对我来说,没有上述工作。 但是,我解决了安装libssl-dev的问题。

sudo apt-get install libssl-dev

如果您的错误消息与我的情况相同,则可能会有效:

致命错误:openssl / opensslv.h:没有这样的文件或目录......   命令'x86_64-linux-gnu-gcc'以退出状态1失败

linux_fan answered 2019-02-14T16:14:51Z

10 votes

在ubuntu 14.04上:

sudo apt-file search ffi.h

回:

chipmunk-dev: /usr/include/chipmunk/chipmunk_ffi.h

ghc-doc: /usr/share/doc/ghc-doc/html/users_guide/ffi.html

jython-doc: /usr/share/doc/jython-doc/html/javadoc/org/python/modules/jffi/jffi.html

libffi-dev: /usr/include/x86_64-linux-gnu/ffi.h

libffi-dev: /usr/share/doc/libffi6/html/Using-libffi.html

libgirepository1.0-dev: /usr/include/gobject-introspection-1.0/girffi.h

libgirepository1.0-doc: /usr/share/gtk-doc/html/gi/gi-girffi.html

mlton-basis: /usr/lib/mlton/include/basis-ffi.h

pypy-doc: /usr/share/doc/pypy-doc/html/config/objspace.usemodules._ffi.html

pypy-doc: /usr/share/doc/pypy-doc/html/config/objspace.usemodules._rawffi.html

pypy-doc: /usr/share/doc/pypy-doc/html/rffi.html

我选择安装libffi-dev

sudo apt-get install libffi-dev

工作得很好

Evyatar Sivan answered 2019-02-14T16:15:37Z

6 votes

尽管这是一个老问题,但我会加上我的观点。

我认为正确的答案取决于gcc编译器的错误信息,如“Missing xxxx.h”

在某些情况下这可能有所帮助:

sudo apt-get install build-essential python-dev

user2106495 answered 2019-02-14T16:16:15Z

4 votes

以下答案对我有用,你可以尝试:

sudo apt-get install python3-lxml

user6393832 answered 2019-02-14T16:16:41Z

3 votes

提示:请不要将此视为答案。 只是为了帮助别人。

我在安装psycopg2时遇到了类似的问题。 我安装了psycopg2,python-dev以及libpq-dev,但它抛出了同样的错误。

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

因为我急于部署所以最后只是复制了全线@ user3440631的回答。

sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev

它就像一个魅力。 但找不到哪个包解决了我的问题。如果有人从上面的命令了解psycopg2依赖包,请更新评论。

Laxmikant answered 2019-02-14T16:17:30Z

3 votes

在我的情况下pip无法安装库,我尝试了上面给出的解决方案,但没有一个工作,但以下工作对我来说:

sudo apt update gcc

yunus answered 2019-02-14T16:17:56Z

2 votes

今天用pip升级我的电脑,并在这里检查其他答案,我可以告诉你它可能是任何东西。 您应该逐个检查错误,查找您需要的特定库。 就我而言,这些是我必须安装的库:

$ sudo apt-get install libssl-dev

$ sudo apt-get install libffi-dev

$ sudo apt-get install libjpeg-dev

$ sudo apt-get install libvirt-dev

$ sudo apt-get install libsqlite3-dev

$ sudo apt-get install libcurl4-openssl-dev

$ sudo apt-get install libxml2-dev libxslt1-dev python-dev

HTH

Mario S answered 2019-02-14T16:18:25Z

2 votes

sudo easy_install gevent

sudo easy_install gevent

sudo easy_install gevent

Yogesh Nikam Patil answered 2019-02-14T16:18:56Z

2 votes

使用运行python 3.5的Ubuntu 14.04 LTS和virtualenv,我必须这样做:

sudo apt-get install python3.5-dev

其他命令:

sudo apt-get install python-dev

sudo apt-get install python3-dev

没有帮助。 我想这是因为virtualenv需要依赖系统级的python-dev封装,它必须与virtualenv的python版本相匹配。 但是,使用上面的命令为python 2.x安装python-dev,为Ubuntu 14.04安装的python 3.x为3.4,而不是3.5。

Deleet answered 2019-02-14T16:19:38Z

2 votes

对我来说,我必须确保使用正确版本的加密。pip.freeze有和旧版本,一旦我使用了最新的问题。

Morvis13 answered 2019-02-14T16:20:06Z

2 votes

首先,你需要找出实际问题是什么。 你看到的是C编译器失败但你还不知道为什么。 向上滚动到原始错误的位置。 在我的情况下,尝试使用pip3安装一些软件包,我发现:

Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-4u59c_8b/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-itjeh3va-record/install-record.txt --single-version-externally-managed --compile --user:

c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

#include

^

compilation terminated.

所以在我的情况下,我需要安装libffi-dev。

jcomeau_ictx answered 2019-02-14T16:20:43Z

2 votes

错误:错误:命令'x86_64-linux-gnu-gcc'因退出状态1而失败

执行sudo apt-get install python-dev解决了错误。

Suky answered 2019-02-14T16:21:19Z

2 votes

这适用于我,12.04,python2.7.6

sudo apt-get install libxml2 libxml2-dev libxslt1-dev

sudo apt-get install lxml

Jesse Yan answered 2019-02-14T16:21:56Z

1 votes

当我在Ubuntu 14.04上遇到同样的问题时,上述答案都不适用于我

但是,这解决了错误:

sudo apt-get install python-numpy libicu-dev

musicakc answered 2019-02-14T16:22:39Z

1 votes

对我来说,它有助于安装libxml2-dev和libxslt1-dev。

sudo apt-get install libxml2-dev

Primoz answered 2019-02-14T16:23:10Z

1 votes

我的堆栈是这样的:

> > ^

> > In file included from /usr/include/openssl/ssl.h:156:0,

> > from OpenSSL/crypto/x509.h:17,

> > from OpenSSL/crypto/crypto.h:17,

> > from OpenSSL/crypto/crl.c:3:

> > /usr/include/openssl/x509.h:751:15: note: previous declaration of ‘X509_REVOKED_dup’ was here

> > X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);

> > ^

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

> >

> > ---------------------------------------- Rolling back uninstall of > pyOpenSSL Command "/home/marta/env/pb/bin/python -u -c

> "import setuptools,

> > tokenize;__file__='/tmp/pip-build-14ekWY/pyOpenSSL/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-2HERvW-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/marta/env/pb/include/site/python2.7/pyOpenSSL" failed with error

> > code 1 in /tmp/pip-build-14ekWY/pyOpenSSL/

在同一情况下,请考虑其中一个安装文件中的拼写错误(bug),并通过将“X509_REVOKED_dup”更改为“X509_REVOKED_dupe”(无引号)手动编辑它。 我编辑了x509.h文件:

sed -e's / X509_REVOKED_dup / X509_REVOKED_dupe / g'-i  USR /包含/ OpenSSL的/ x509.h

它对我有用,但请参考下面链接的帖子,因为他们编辑了另一个文件:

sed -e's / X509_REVOKED_dup / X509_REVOKED_dupe / g'-i OpenSSL / crypto / crl.c

[https://groups.google.com/forum/#!topic/kivy-users/Qt0jNIOACZc]

fanny answered 2019-02-14T16:24:17Z

0 votes

对于Centos 7使用以下命令安装Python开发包

Python 2.7

sudo yum安装python-dev

Python 3.4

sudo yum安装python34-devel

如果您的问题没有解决,请尝试安装以下包 -

sudo yum安装libffi-devel

sudo yum安装openssl-devel

Rahul Satal answered 2019-02-14T16:25:28Z

0 votes

就像罗宾温斯洛在评论中所说:

我在这里找到了我的解决方案:stackoverflow.com/a/5178444/613540

就我而言,我的完整错误消息是:

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

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

我试图安装torrench:

sudo python3 setup.py install

使用给定的stackoverflow链接,我通过以下方式解决了这个问题:

sudo apt install zlib1g-dev

请注意,已安装以下软件包:

libxslt1-dev is already the newest version.

python3-dev is already the newest version.

libxml2-dev is already the newest version.

希望有所帮助!

Vetea answered 2019-02-14T16:26:45Z

0 votes

在我的情况下,导致相同(通用)错误的是libmysqlcppconn-dev。

In file included from oursqlx/oursql.c:236:0:

oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory

compilation terminated.

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

----------------------------------------

Failed building wheel for oursql

Running setup.py clean for oursql

所以,我知道我需要libmysqlcppconn-dev包。

sudo apt-get install libmysqlcppconn-dev

一切都好!

Jay Modi answered 2019-02-14T16:27:29Z

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值