标签归档:gcc

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

问题:安装脚本退出,并显示错误:命令’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

谁能帮我解决这个问题?

When I try to install odoo-server, I got the following error:

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

Could anyone help me to solve this issue?


回答 0

我在大学的最后一年的主要项目中安装了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,请x用中的次要版本替换

$ sudo apt-get install python3.x-dev

I encountered the same problem in college having installed Linux Mint for the main project of my final year, the third solution below worked for me.

When encountering this error please note before the error it may say you are missing a package or header file — you should find those and install them and verify if it works (e.g. ssl → libssl).

For Python 2.x use:

$ sudo apt-get install python-dev

For Python 2.7 use:

$ sudo apt-get install libffi-dev

For Python 3.x use:

$ sudo apt-get install python3-dev

or for a specific version of Python 3, replace x with the minor version in

$ sudo apt-get install python3.x-dev

回答 1

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/

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications.

enter:

$ sudo apt-get install python-dev

or

# apt-get install python-dev

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


回答 2

尝试安装这些软件包。

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

Try installing these packages.

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

回答 3

您需要安装以下软件包:

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

You need to install these packages:

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

回答 4

$ 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
$ 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

OR TRY THIS:

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

回答 5

对于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

对于Python 3.7,请使用:

sudo apt-get install python3.7-dev

对于Python 3.8,请使用:

sudo apt-get install python3.8-dev

… 等等 …

For Python 3.4 use:

sudo apt-get install python3.4-dev

For Python 3.5 use:

sudo apt-get install python3.5-dev

For Python 3.6 use:

sudo apt-get install python3.6-dev

For Python 3.7 use:

sudo apt-get install python3.7-dev

For Python 3.8 use:

sudo apt-get install python3.8-dev

… and so on …


回答 6

对我而言,以上方法均无效。但是,我解决了安装问题libssl-dev

sudo apt-get install libssl-dev

如果您遇到与我的情况相同的错误消息,这可能会起作用:

致命错误:openssl / opensslv.h:没有此类文件或目录…..命令’x86_64-linux-gnu-gcc’失败,退出状态为1

For me none of above worked. However, I solved problem with installing libssl-dev.

sudo apt-get install libssl-dev

This might work if you have same error message as in my case:

fatal error: openssl/opensslv.h: No such file or directory … …. command ‘x86_64-linux-gnu-gcc’ failed with exit status 1


回答 7

就我而言,它缺少软件包libffi-dev

什么有效:

sudo apt-get install libffi-dev

In my case, it was missing package libffi-dev.

What worked:

sudo apt-get install libffi-dev

回答 8

在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

工作完美

on ubuntu 14.04:

sudo apt-file search ffi.h 

returned:

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

I chose to install libffi-dev

sudo apt-get install libffi-dev

worked perfectly


回答 9

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

sudo apt upgrade gcc

In my case pip was unable to install libraries, I tried solutions given above, but none worked but the below worked for me:

sudo apt upgrade gcc

回答 10

尽管是一个老问题,我还是会加我的意见。

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

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

sudo apt-get install build-essential python-dev

Despite being an old question, I’ll add my opinion.

I think the right answer depends on the error message of the gcc compiler, something like “Missing xxxx.h”

This might help in some cases:

sudo apt-get install build-essential python-dev

回答 11

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

sudo apt-get install python3-lxml

below answer worked for me, you can try:

sudo apt-get install python3-lxml

回答 12

错误:错误:命令“ x86_64-linux-gnu-gcc”失败,退出状态为1

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

Error : error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1

Executing sudo apt-get install python-dev solved the error.


回答 13

virtualenv运行Python 3.5的情况下使用Ubuntu 14.04 LTS ,我必须这样做:

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-dev将为python 2.x和Ubuntu 14.04随附的python 3.x(3.4,而非3.5)安装。

Using Ubuntu 14.04 LTS with a virtualenv running python 3.5, I had to do:

sudo apt-get install python3.5-dev

The other commands:

sudo apt-get install python-dev
sudo apt-get install python3-dev

Did not help. I think this is because the virtualenv needs to rely on the system-wide python-dev package and it must match the virtualenv‘s python version. However, using the above commands installs python-dev for python 2.x and the python 3.x that comes with Ubuntu 14.04 which is 3.4, not 3.5.


回答 14

这对我有效,12.04,python2.7.6

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

This works for me, 12.04, python2.7.6

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

回答 15

这对我来说足够了:

sudo apt-get install build-essential

This was enough for me:

sudo apt-get install build-essential

回答 16

今天用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

高温超导

After upgrade my computer with pip today, and check the other answers here, I can tell you that it could be ANYTHING. You should check error by error, looking for what’s the specific library that you need. In my case, these were the libraries that I had to install:

$ 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


回答 17

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

安装psycopg2时遇到类似的问题。我装了build-essentialpython-devlibpq-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从上面的命令中了解依赖包,请更新注释。

Tip: Please do not consider this as an answer. Just to help someone else too.

I had similar issue while installing psycopg2. I installedbuild-essential, python-dev and also libpq-dev but it thrown same error.

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

As I was in hurry in deployment so finally just copied full line from @user3440631’s answer.

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

And It worked like a charm. but could not find which package has resolved my issue. Please update the comment if anyone have idea about psycopg2 dependancy package from above command.


回答 18

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

很多时间,我在安装M2Cryptopygraphviz并安装批准的答案中提到的所有内容时遇到相同的错误。但这行也解决了我在批准的答案中使用其他软件包的所有问题。

sudo apt-get install libssl-dev swig
sudo apt-get install -y graphviz-dev

swig包救了我的生命,为解决方案M2Cryptographviz-devpygraphviz。希望对您有所帮助。

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

Lot of time I got the same error when installing M2Crypto & pygraphviz and installed all the things mention in the approved answer. But this below line solved all my problems with the other packages in approved answer too.

sudo apt-get install libssl-dev swig
sudo apt-get install -y graphviz-dev

This swig package saved my life as the solution for M2Crypto and graphviz-dev for pygraphviz. I hope this will help someone.


回答 19

对我来说,我必须确保使用的是正确的加密版本。pip.freeze有较旧的版本,并且在离开时我使用最新的问题。

For me I had to make sure I was using the correct version of cryptography. pip.freeze had and older version and once I used the latest the problem when away.


回答 20

首先,您需要找出实际的问题是什么。您看到的是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 <ffi.h>

                 ^

compilation terminated.

所以就我而言,我需要安装libffi-dev

first you need to find out what the actual problem was. what you’re seeing is that the C compiler failed but you don’t yet know why. scroll up to where you get the original error. in my case, trying to install some packages using pip3, I found:

    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 <ffi.h>

                 ^

compilation terminated.

so in my case I needed to install libffi-dev.


回答 21

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

sudo easy_install greenlet

sudo easy_install gevent
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

sudo easy_install greenlet

sudo easy_install gevent

回答 22

当我在Ubuntu 14.04上遇到相同的问题时,以上答案均对我不起作用

但是,这解决了错误:

sudo apt-get install python-numpy libicu-dev

None of the above answers worked for me when I had the same issue on my Ubuntu 14.04

However, this solved the error:

sudo apt-get install python-numpy libicu-dev


回答 23

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

sudo apt-get install libxml2-dev

For me it helped to install libxml2-dev and libxslt1-dev.

sudo apt-get install libxml2-dev

回答 24

我的堆栈是这样的:

> >                            ^
> >     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/

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

sed -e’s / X509_REVOKED_dup / X509_REVOKED_dupe / g’-i usr / include / openssl / x509.h

它对我有用,但是当他们编辑另一个文件时,请查阅下面链接的文章:

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

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

My stack was like that:

> >                            ^
> >     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/

in the same case, please consider the typo (bug) in one of the installation files and edit it manually by changing “X509_REVOKED_dup” to “X509_REVOKED_dupe” (no quotes). I have edited the x509.h file:

sed -e’s/X509_REVOKED_dup/X509_REVOKED_dupe/g’ -i usr/include/openssl/x509.h

and it worked for me, but please consult with the post linked below, as they edited another file:

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

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


回答 25

就我而言,该命令sudo apt-get install unixodbc-dev解决了该问题。我收到特定于sql.h头文件的错误。

In my case the command sudo apt-get install unixodbc-dev resolved the issue. I was getting an error specific to the sql.h header file.


回答 26

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

Python 2.7

须藤百胜安装python-dev

Python 3.4

须藤百胜安装python34-devel

如果您的问题仍未解决,请尝试安装以下软件包-

sudo yum安装libffi-devel

须藤yum install openssl-devel

For Centos 7 Use below command to install Python Development Package

Python 2.7

sudo yum install python-dev

Python 3.4

sudo yum install python34-devel

Still if your problem not solved then try installing below packages –

sudo yum install libffi-devel

sudo yum install openssl-devel


回答 27

就像罗宾·温斯洛Robin Winslow)在评论中说的那样:

我在这里找到了解决方案: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.

希望对您有所帮助!

Like Robin Winslow says in a comment :

I found my solution over here: stackoverflow.com/a/5178444/613540

In my case, my complete error message was :

/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

I was trying to install torrench :

sudo python3 setup.py install

With given stackoverflow link, I solve this issue by :

sudo apt install zlib1g-dev

Note that the following packages were already installed :

libxslt1-dev is already the newest version.
python3-dev is already the newest version.
libxml2-dev is already the newest version.

Hope that will help !


回答 28

在我的情况下,这是oursql导致以下相同(通用)错误的原因。

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

一切都很好!

In my case, it was oursql that was causing the same(generic) error as below.

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

So, I knew that I need to have libmysqlcppconn-dev package.

sudo apt-get install libmysqlcppconn-dev

And all good!


回答 29

这为我工作:

sudo apt安装zlib1g-dev

This Worked for me:

sudo apt install zlib1g-dev


致命错误:Python.h:没有这样的文件或目录

问题:致命错误:Python.h:没有这样的文件或目录

我正在尝试使用C扩展文件构建共享库,但首先我必须使用以下命令生成输出文件:

gcc -Wall utilsmodule.c -o Utilc

执行命令后,我得到以下错误消息:

utilsmodule.c:1:20:致命错误:Python.h:没有此类文件或目录编译终止。

我已经尝试了所有建议的解决方案,但是仍然存在该问题。我没有问题Python.h。我设法在机器上找到该文件。

I am trying to build a shared library using a C extension file but first I have to generate the output file using the command below:

gcc -Wall utilsmodule.c -o Utilc

After executing the command, I get this error message:

utilsmodule.c:1:20: fatal error: Python.h: No such file or directory compilation terminated.

I have tried all the suggested solutions over the internet but the problem still exists. I have no problem with Python.h. I managed to locate the file on my machine.


回答 0

看来您尚未正确安装python dev的标头文件和静态库。使用软件包管理器在系统范围内安装它们。

对于aptUbuntu,Debian …):

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs

对于yumCentOS,RHEL …):

sudo yum install python-devel   # for python2.x installs
sudo yum install python3-devel   # for python3.x installs

对于dnfFedora …):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel  # for python3.x installs

对于zypperopenSUSE …):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel  # for python3.x installs

对于apkAlpine …):

# This is a departure from the normal Alpine naming
# scheme, which uses py2- and py3- prefixes
sudo apk add python2-dev  # for python2.x installs
sudo apk add python3-dev  # for python3.x installs

对于apt-cygCygwin …):

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

Looks like you haven’t properly installed the header files and static libraries for python dev. Use your package manager to install them system-wide.

For apt (Ubuntu, Debian…):

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs

For yum (CentOS, RHEL…):

sudo yum install python-devel   # for python2.x installs
sudo yum install python3-devel   # for python3.x installs

For dnf (Fedora…):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel  # for python3.x installs

For zypper (openSUSE…):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel  # for python3.x installs

For apk (Alpine…):

# This is a departure from the normal Alpine naming
# scheme, which uses py2- and py3- prefixes
sudo apk add python2-dev  # for python2.x installs
sudo apk add python3-dev  # for python3.x installs

For apt-cyg (Cygwin…):

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

回答 1

在Ubuntu上,我正在运行Python 3,必须安装

sudo apt-get install python3-dev

如果要使用未链接到python3的Python版本,请安装关联的python3.x-dev软件包。例如:

sudo apt-get install python3.5-dev

On Ubuntu, I was running Python 3 and I had to install

sudo apt-get install python3-dev

If you want to use a version of Python that is not linked to python3, install the associated python3.x-dev package. For example:

sudo apt-get install python3.5-dev

回答 2

特别是对于Python 3.7Ubuntu,我需要

sudo apt install libpython3.7-dev

。我认为在某些时候名称已从此更改pythonm.n-dev

对于Python 3.6,类似地:

sudo apt install libpython3.6-dev

For Python 3.7 and Ubuntu in particular, I needed

sudo apt install libpython3.7-dev

. I think at some point names were changed from pythonm.n-dev to this.


回答 3

您必须做两件事。

为Debian / Ubuntu / Mint安装适用于Python的开发包,可通过以下命令完成:

sudo apt-get install python-dev

第二件事是,默认情况下,包含文件不在包含路径中,Python库也不与可执行文件链接。您需要添加这些标志(相应地替换Python的版本):

-I/usr/include/python2.7 -lpython2.7 

换句话说,您的编译命令应为:

gcc -Wall -I/usr/include/python2.7 -lpython2.7  utilsmodule.c -o Utilc 

Two things you have to do.

Install development package for Python, in case of Debian/Ubuntu/Mint it’s done with command:

sudo apt-get install python-dev

Second thing is that include files are not by default in the include path, nor is Python library linked with executable by default. You need to add these flags (replace Python’s version accordingly):

-I/usr/include/python2.7 -lpython2.7 

In other words your compile command ought to be:

gcc -Wall -I/usr/include/python2.7 -lpython2.7  utilsmodule.c -o Utilc 

回答 4

如果您使用的是Raspberry Pi:

sudo apt-get install python-dev

If you are using a Raspberry Pi:

sudo apt-get install python-dev

回答 5

在Fedora上针对Python 2运行它:

sudo dnf install python2-devel

而对于Python 3:

sudo dnf install python3-devel

on Fedora run this for Python 2:

sudo dnf install python2-devel

and for Python 3:

sudo dnf install python3-devel

回答 6

如果要使用tox在多个版本的Python上运行测试,则可能需要为要测试的每个Python版本安装Python开发库。

sudo apt-get install python2.6-dev 
sudo apt-get install python2.7-dev 
etc.

If you are using tox to run tests on multiple versions of Python, you may need to install the Python dev libraries for each version of Python you are testing on.

sudo apt-get install python2.6-dev 
sudo apt-get install python2.7-dev 
etc.

回答 7

Cygwin的解决方案

您需要安装软件包python2-develpython3-devel,具体取决于您使用的Python版本。

您可以使用Cygwin.com上的32位64位 setup.exe(取决于您的安装)快速安装它。

示例(setup.exe如果需要,可以修改的文件名和Python的主要版本):

$ setup.exe -q --packages=python3-devel

您也可以在其他答案中查看我的其他答案,以从命令行安装Cygwin的软件包。

Solution for Cygwin

You need to install the package python2-devel or python3-devel, depending on the Python version you’re using.

You can quickly install it using the 32-bit or 64-bit setup.exe (depending on your installation) from Cygwin.com.

Example (modify setup.exe‘s filename and Python’s major version if you need):

$ setup.exe -q --packages=python3-devel

You can also check my other answer for a few more options to install Cygwin’s packages from the command-line.


回答 8

在AWS API(centOS)中

yum install python27-devel

In AWS API (centOS) its

yum install python27-devel

回答 9

对我来说,将其更改为有效:

#include <python2.7/Python.h>

我找到了文件/usr/include/python2.7/Python.h,并且由于/usr/include已经在include路径中,因此python2.7/Python.h应该足够了。

您也可以从命令行添加包含路径- gcc -I/usr/lib/python2.7(感谢@ erm3nda)。

For me, changing it to this worked:

#include <python2.7/Python.h>

I found the file /usr/include/python2.7/Python.h, and since /usr/include is already in the include path, then python2.7/Python.h should be sufficient.

You could also add the include path from command line instead – gcc -I/usr/lib/python2.7 (thanks @erm3nda).


回答 10

确保您的操作系统随附Python开发文件。

您不应该对库进行硬编码并包含路径。而是使用pkg-config,它将为您的特定系统输出正确的选项:

$ pkg-config --cflags --libs python2 -I/usr/include/python2.7 -lpython2.7

您可以将其添加到您的gcc行:

gcc -Wall utilsmodule.c -o Utilc $(pkg-config --cflags --libs python2) 

Make sure that the Python dev files come with your OS.

You should not hard code the library and include paths. Instead, use pkg-config, which will output the correct options for your specific system:

$ pkg-config --cflags --libs python2 -I/usr/include/python2.7 -lpython2.7

You may add it to your gcc line:

gcc -Wall utilsmodule.c -o Utilc $(pkg-config --cflags --libs python2) 

回答 11

运行python34的AWS EC2安装:

sudo yum install python34-devel

AWS EC2 install running python34:

sudo yum install python34-devel


回答 12

就我而言,在Ubuntu中修复该问题的是安装软件包libpython-all-dev(或者libpython3-all-dev如果您使用Python 3)。

In my case, what fixed it in Ubuntu was to install the packages libpython-all-dev (or libpython3-all-dev if you use Python 3).


回答 13

如果您使用带有3.6 python的virtualenv(现在是edge),请确保安装匹配的python 3.6 dev sudo apt-get install python3.6-dev,否则执行sudo python3-dev将安装python dev 3.3.3-1,这将无法解决问题。

If you use a virtualenv with a 3.6 python (edge right now), be sure to install the matching python 3.6 dev sudo apt-get install python3.6-dev, otherwise executing sudo python3-dev will install the python dev 3.3.3-1, which won’t solve the issue.


回答 14

情况不一样,但对我也适用,现在我可以在Python3.5中使用SWIG了:

我正在尝试编译:

gcc -fPIC -c existe.c existe_wrap.c -I /usr/include/python3.5m/

使用Python 2.7可以正常工作,而不能用于我的3.5版本:

existe_wrap.c:147:21:致命错误:Python.h:没有存档或目录编译终止。

在我的Ubuntu 16.04安装中运行后:

sudo apt-get install python3-dev  # for python3.x installs

现在,我可以毫无问题地编译Python3.5了:

gcc -fPIC -c existe.c existe_wrap.c -I /usr/include/python3.5m/

It’s not the same situation, but it also works for me and now I can use SWIG with Python3.5:

I was trying to compile:

gcc -fPIC -c existe.c existe_wrap.c -I /usr/include/python3.5m/

With Python 2.7 works fine, not with my version 3.5:

existe_wrap.c:147:21: fatal error: Python.h: No existe el archivo o el directorio compilation terminated.

After run in my Ubuntu 16.04 installation:

sudo apt-get install python3-dev  # for python3.x installs

Now I can compile without problems Python3.5:

gcc -fPIC -c existe.c existe_wrap.c -I /usr/include/python3.5m/

回答 15

我在ubuntu中安装coolprop时也遇到了此错误。

对于带有python 3.6的ubuntu 16.04

sudo apt-get install python3.6-dev

如果这不起作用,请尝试安装/更新gcclib。

sudo apt-get install gcc

I also encountered this error when I was installing coolprop in ubuntu.

For ubuntu 16.04 with python 3.6

sudo apt-get install python3.6-dev

If ever this doesn’t work try installing/updating gcc lib.

sudo apt-get install gcc

回答 16

尝试apt文件。很难记住丢失文件所在的软件包名称。它是通用的,对任何软件包文件都有用。

例如:

root@ubuntu234:~/auto# apt-file search --regexp '/Python.h$'
pypy-dev: /usr/lib/pypy/include/Python.h
python2.7-dbg: /usr/include/python2.7_d/Python.h
python2.7-dev: /usr/include/python2.7/Python.h
python3.2-dbg: /usr/include/python3.2dmu/Python.h
python3.2-dev: /usr/include/python3.2mu/Python.h
root@ubuntu234:~/auto# 

现在,您可以对要选择的专家进行猜测。

try apt-file. It is difficult to remember the package name where the missing file resides. It is generic and useful for any package files.

For example:

root@ubuntu234:~/auto# apt-file search --regexp '/Python.h$'
pypy-dev: /usr/lib/pypy/include/Python.h
python2.7-dbg: /usr/include/python2.7_d/Python.h
python2.7-dev: /usr/include/python2.7/Python.h
python3.2-dbg: /usr/include/python3.2dmu/Python.h
python3.2-dev: /usr/include/python3.2mu/Python.h
root@ubuntu234:~/auto# 

Now you can make an expert guess as to which one to choose from.


回答 17

我设法解决了这个问题,并在一个命令中生成了.so文件

gcc -shared -o UtilcS.so
-fPIC -I/usr/include/python2.7 -lpython2.7  utilsmodule.c

I managed to solve this issue and generate the .so file in one command

gcc -shared -o UtilcS.so
-fPIC -I/usr/include/python2.7 -lpython2.7  utilsmodule.c

回答 18

对于OpenSuse同志:

sudo zypper install python3-devel

For the OpenSuse comrades out there:

sudo zypper install python3-devel

回答 19

对于CentOS 7:

sudo yum install python36u-devel

我按照此处的说明在多个VM上安装python3.6:https ://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming- 在centos-7上运行 ,然后能够构建mod_wsgi并使其与python3.6 virtualenv一起使用

For CentOS 7:

sudo yum install python36u-devel

I followed the instructions here for installing python3.6 on several VMs: https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-centos-7 and was then able to build mod_wsgi and get it working with a python3.6 virtualenv


回答 20

如果您在Amazon Linux上使用Python 3.6(基于RHEL,但此处给出的RHEL答案无效):

sudo yum install python36-devel

If you’re using Python 3.6 on Amazon Linux (based on RHEL, but the RHEL answers given here didn’t work):

sudo yum install python36-devel

回答 21

当我尝试使用Python3.6在CentOS 7上安装ctds时发生此错误。我做了这里提到的所有技巧,包括yum install python34-devel。在Python.h中发现了问题/usr/include/python3.4m but not in /usr/include/python3.6m。我试图--global-option指向包含dir(pip3.6 install --global-option=build_ext --global-option="--include-dirs=/usr/include/python3.4m" ctds)的位置。导致在lpython3.6m链接ctds时找不到。

最后,有效的方法是修复Python3.6的开发环境,需要使用include和libs进行更正。

yum -y install https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/python36u-libs-3.6.3-1.ius.centos7.x86_64.rpm

Python.h必须位于gcc的包含路径中。无论使用哪个版本的python(例如,如果版本为3.6,则/usr/include/python3.6m/Python.h通常都应使用该版本)。

This error occurred when I attempted to install ctds on CentOS 7 with Python3.6. I did all the tricks mentioned here including yum install python34-devel. The problem was Python.h was found in /usr/include/python3.4m but not in /usr/include/python3.6m. I tried to use --global-option to point to include dir (pip3.6 install --global-option=build_ext --global-option="--include-dirs=/usr/include/python3.4m" ctds). This resulted in a lpython3.6m not found when linking ctds.

Finally what worked was fixing the development environment for Python3.6 needs to correct with the include and libs.

yum -y install https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/python36u-libs-3.6.3-1.ius.centos7.x86_64.rpm

Python.h needs to be in your include path for gcc. Whichever version of python is used, for example if it’s 3.6, then it should be in /usr/include/python3.6m/Python.h typically.


回答 22

当然,python-dev还是libpython-all-devapt)的第一件事install,但是,如果这对我的情况没有帮助,我建议您通过和安装外部功能接口软件包。sudo apt-get install libffi-devsudo pip install cffi

如果您看到错误信息as / from,这应该会有所帮助c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory

Sure python-dev or libpython-all-dev are the first thing to (apt )install, but if that doesn’t help as was my case, I advice you to install the foreign Function Interface packages by sudo apt-get install libffi-dev and sudo pip install cffi.

This should help out especially if you see the error as/from c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory.


回答 23

当您尝试删除python3.5和安装时,它经常出现python3.6

因此,当使用python3(which python3 -V=> python3.6)安装某些软件包时,所需的python3.5标头将出现此错误。

通过安装python3.6-dev模块解决。

It often appear when you trying to remove python3.5 and install python3.6.

So when using python3 (which python3 -V => python3.6) to install some packages required python3.5 header will appear this error.

Resolve by install python3.6-dev module.


回答 24

  1. 如果操作系统随附的Python不附带Python开发文件,则必须在其上安装Python开发文件。关于这个问题的许多答案显示了在不同系统上可以实现的无数种方法。

  2. 您这样做时,问题是告诉编译器它们的位置以及如何针对它们进行编译。Python附带了一个名为的程序python-config。对于编译,您需要--includes输出,并且需要将程序链接到Python库(将Python嵌入程序中)到--ldflags输出。例:

    gcc -c mypythonprogram.c $(python3-config --includes)
    gcc -o program mypythonprogram.o $(python3-config --ldflags)

python-config程序可以以Python版本命名-例如在Debian,Ubuntu上,它们可以命名为python3-configpython3.6-config

  1. You must install the Python development files on your operating system if the Python provided with your operating system does not come with them. The many answers on this question show the myriad ways this can be achieved on different systems.

  2. When you have done so, the problem is telling the compiler where they’re located and how to compile against them. Python comes with a program called python-config. For compilation, you need the --includes output and for linking a program against the Python library (embedding Python into your program) the --ldflags output. Example:

    gcc -c mypythonprogram.c $(python3-config --includes)
    gcc -o program mypythonprogram.o $(python3-config --ldflags)
    

The python-config program can be named after the Python versions – on Debian, Ubuntu for example these can be named python3-config or python3.6-config.


回答 25

有时即使安装了python-dev之后,错误仍然存​​在,如果没有’gcc’,请检查错误。

首先按照https://stackoverflow.com/a/21530768/8687063中的说明进行下载,然后安装gcc

对于apt(Ubuntu,Debian …):

sudo apt-get install gcc

对于百胜(CentOS,RHEL …):

sudo yum install gcc

对于dnf(Fedora …):

sudo dnf install gcc

对于zypper(openSUSE …):

sudo zypper in gcc

对于apk(高山…):

sudo apk gcc

Sometimes even after installing python-dev the error persists, Check for the error if it is ‘gcc’ missing.

First download as stated in https://stackoverflow.com/a/21530768/8687063, then install gcc

For apt (Ubuntu, Debian…):

sudo apt-get install gcc

For yum (CentOS, RHEL…):

sudo yum install gcc

For dnf (Fedora…):

sudo dnf install gcc

For zypper (openSUSE…):

sudo zypper in gcc

For apk (Alpine…):

sudo apk gcc

回答 26

这意味着它Python.h不在编译器的默认包含路径中。您在系统范围内还是在本地安装了它?您的操作系统是什么?

您可以使用该-I<path>标志指定编译器应在其中查找标头的其他目录。您可能需要跟进,-L<path>以便gcc可以找到要使用链接的库-l<name>

This means that Python.h isn’t in your compiler’s default include paths. Have you installed it system-wide or locally? What’s your OS?

You could use the -I<path> flag to specify an additional directory where your compiler should look for headers. You will probably have to follow up with -L<path> so that gcc can find the library you’ll be linking with using -l<name>.