Environment: Linux Mint 17 Cinnamon.
环境:Linux薄荷17肉桂。
This error is displayed:
这个错误是显示:
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
when attempting the following in a virtualenv
:
当在虚拟环境中尝试以下操作时:
pip install lxml
pip install pillow
pip install pycrypto
pip install pymongo (fails but still shows in pip freeze)
There are several solutions here that recommend installing python2.7-dev
:
这里有几种解决方案建议安装python2.7-dev:
安装错误:安装脚本错误:命令'x86_64-linux-gnu-gcc'失败与退出状态1。
Installing lxml in virtualenv via pip install error: command 'x86_64-linux-gnu-gcc' failed
通过pip安装错误在virtualenv中安装lxml:命令“x86_64-linux-gnu-gcc”失败。
Pillow installation error: command 'gcc' failed with exit status 1
枕头安装错误:命令“gcc”以退出状态1失败。
fatal error: Python.h: No such file or directory
致命错误:Python。h:没有这样的文件或目录。
I am confused by this recommendation however because it is my understanding that using something like:
我对这个建议感到困惑,因为我的理解是:
sudo apt-get install python2.7-dev
would add this to the main *system* instance of Python, rather that the one in virtualenv
. (see - https://unix.stackexchange.com/a/56392/92486)
将其添加到Python的主要*系统*实例中,而不是在virtualenv中。(参见https://unix.stackexchange.com/a/56392/92486)
Can I add python2.7-dev
just to the virtualenv
version of Python?
我可以将python2.7-dev添加到Python的virtualenv版本吗?
9 个解决方案
#1
18
Most of the time these are dependency-issues.
大多数情况下,这些都是依赖性问题。
Following the stack-trace of the gcc compiler one can see the missing files. Sometimes installing the Python development packages is not enough.
跟踪gcc编译器的堆栈跟踪后,可以看到丢失的文件。有时候安装Python开发包是不够的。
For example: I tried to do pip install requests[security]
in my virtualenv foo. This is the result that the pip-installer gave me.
例如:我尝试在我的virtualenv foo中执行pip安装请求[安全性]。这是pip安装程序给我的结果。
Failed building wheel for cryptography
Running setup.py bdist_wheel for cffi
Stored in directory: /root/.cache/pip/wheels/99/e7/9a/68b1c8ca6f6f92b5feebd4d9434f50712b84f6a66d1285ea21
Successfully built cffi
Failed to build cryptography
Installing collected packages: cffi, cryptography, pyOpenSSL, ndg-httpsclient, requests
Running setup.py install for cryptography
Complete output from command /opt/foo/django-cms-virtualenv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-eZaLAG/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BwgYTp-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/foo/django-cms-virtualenv/include/site/python2.7/cryptography:
running install
running build
running build_py
running egg_info
writing requirements to src/cryptography.egg-info/requires.txt
writing src/cryptography.egg-info/PKG-INFO
writing top-level names to src/cryptography.egg-info/top_level.txt
writing dependency_links to src/cryptography.egg-info/dependency_links.txt
writing entry points to src/cryptography.egg-info/entry_points.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
warning: no previously-included files matching '*' found under directory 'vectors'
writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
running build_ext
building '_Cryptography_cffi_a269d620xd5c405b7' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c -o build/temp.linux-x86_64-2.7/src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.o
src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c:217:25: fatal error: openssl/aes.h: Datei oder Verzeichnis nicht gefunden
#include <openssl/aes.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
The important part is the: #include <openssl/aes.h>
重要的部分是:#include
The compiler makes pretty clear that it is demanding this file - but it is not there in the filesystem.
编译器清楚地表明它要求这个文件——但它不在文件系统中。
Knowing that, the only thing left to do is: install the needed libraries!
知道了这一点,剩下要做的事情就是:安装所需的库!
- Find out which package is needed for your distribution: e.g. for Ubuntu you can go to The Ubuntu Package Search Site and enter the missing file you are looking for. In this case "aes.h"
- 找出你的发行版需要哪些包:例如Ubuntu,你可以去Ubuntu包搜索网站,输入你正在寻找的文件。在这种情况下“aes.h”
-
Install the needed packages using your distributions package management tool: e.g. for Ubuntu:
使用您的发行包管理工具安装所需的包:例如Ubuntu:
aptitude install libssl-dev
才能安装libssl-dev
-
Retry with pip in your virtualenv:
在你的virtualenv中重试pip:
pip install requests[security]
pip安装要求(安全)
#2
16
I installed python2.7-dev
via Synaptic Package Manager in Linux Mint 17.
我在Linux Mint 17中通过Synaptic软件包管理器安装了python2.7-dev。
I could then accomplish the following in virtualenv
:
然后我可以在virtualenv中完成以下任务:
pip install pillow
pip install pycrypto
And then I installed libxml2-dev
and libxslt1-dev
via Synaptic and could accomplish the following:
然后我通过Synaptic安装libxml2-dev和libxslt1-dev,可以完成以下操作:
pip install lxml
I also did this so that the pymongo install didn't have any errors:
我也这样做了,所以pymongo安装没有任何错误:
pip uninstall pymongo
pip install pymongo # i defined the version i needed ie pip install pymongo==2.6.2
I'm still confused how this fixes the problem, because I thought virtualenv
was an isolated environment. Any clarification about this appreciated.
我仍然搞不清楚这是如何解决问题的,因为我认为virtualenv是一个孤立的环境。对此有任何的澄清。
#3
5
Work for me :
Just install python2.7-dev first sudo apt-get install python2.7-dev
为我工作:安装python2.7-dev first sudo apt-get安装python2.7-dev。
#4
2
In Ubuntu 16.04.1 this worked for me:
在Ubuntu 16.04.1中,这对我有用:
sudo apt-get install libxml2-dev libxslt1-dev python-dev
#5
1
For me the installation of lxml was failing on compilation. I followed the instructions for installation of lxml and reduced the compiler optimizations:
对我来说,lxml的安装失败了。我遵循了lxml的安装说明,并减少了编译器的优化:
sudo CFLAGS="-O0" pip install lxml
After doing this, the compile of lxml succeeded.
这样做之后,lxml的编译成功了。
#6
0
This can be a problem in the pip. To solve, try:
这可能是pip中的一个问题。尝试解决:
sudo apt-get remove python-pip
sudo apt-get删除python-pip
To install pip, securely download get-pip.py.
安装pip,安全下载get-pip.py。
https://bootstrap.pypa.io/get-pip.py
https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo python get-pip.py
#7
0
The cffi
library needs libffi-dev
:
cffi图书馆需要libf -dev:
sudo apt-get install libffi libffi-dev
#8
0
Easiest way is:
简单的方法是:
sudo apt-get build-dep python-imaging
and then
然后
pip install pillow
#9
0
This works for me, 12.04, python2.7.6 for package lxml
这对我来说,12.04,python2.7.6包装lxml。
sudo pip install libxml2 libxml2-dev libxslt1-dev
sudo pip install lxml
#1
18
Most of the time these are dependency-issues.
大多数情况下,这些都是依赖性问题。
Following the stack-trace of the gcc compiler one can see the missing files. Sometimes installing the Python development packages is not enough.
跟踪gcc编译器的堆栈跟踪后,可以看到丢失的文件。有时候安装Python开发包是不够的。
For example: I tried to do pip install requests[security]
in my virtualenv foo. This is the result that the pip-installer gave me.
例如:我尝试在我的virtualenv foo中执行pip安装请求[安全性]。这是pip安装程序给我的结果。
Failed building wheel for cryptography
Running setup.py bdist_wheel for cffi
Stored in directory: /root/.cache/pip/wheels/99/e7/9a/68b1c8ca6f6f92b5feebd4d9434f50712b84f6a66d1285ea21
Successfully built cffi
Failed to build cryptography
Installing collected packages: cffi, cryptography, pyOpenSSL, ndg-httpsclient, requests
Running setup.py install for cryptography
Complete output from command /opt/foo/django-cms-virtualenv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-eZaLAG/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BwgYTp-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/foo/django-cms-virtualenv/include/site/python2.7/cryptography:
running install
running build
running build_py
running egg_info
writing requirements to src/cryptography.egg-info/requires.txt
writing src/cryptography.egg-info/PKG-INFO
writing top-level names to src/cryptography.egg-info/top_level.txt
writing dependency_links to src/cryptography.egg-info/dependency_links.txt
writing entry points to src/cryptography.egg-info/entry_points.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
warning: no previously-included files matching '*' found under directory 'vectors'
writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
running build_ext
building '_Cryptography_cffi_a269d620xd5c405b7' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c -o build/temp.linux-x86_64-2.7/src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.o
src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c:217:25: fatal error: openssl/aes.h: Datei oder Verzeichnis nicht gefunden
#include <openssl/aes.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
The important part is the: #include <openssl/aes.h>
重要的部分是:#include
The compiler makes pretty clear that it is demanding this file - but it is not there in the filesystem.
编译器清楚地表明它要求这个文件——但它不在文件系统中。
Knowing that, the only thing left to do is: install the needed libraries!
知道了这一点,剩下要做的事情就是:安装所需的库!
- Find out which package is needed for your distribution: e.g. for Ubuntu you can go to The Ubuntu Package Search Site and enter the missing file you are looking for. In this case "aes.h"
- 找出你的发行版需要哪些包:例如Ubuntu,你可以去Ubuntu包搜索网站,输入你正在寻找的文件。在这种情况下“aes.h”
-
Install the needed packages using your distributions package management tool: e.g. for Ubuntu:
使用您的发行包管理工具安装所需的包:例如Ubuntu:
aptitude install libssl-dev
才能安装libssl-dev
-
Retry with pip in your virtualenv:
在你的virtualenv中重试pip:
pip install requests[security]
pip安装要求(安全)
#2
16
I installed python2.7-dev
via Synaptic Package Manager in Linux Mint 17.
我在Linux Mint 17中通过Synaptic软件包管理器安装了python2.7-dev。
I could then accomplish the following in virtualenv
:
然后我可以在virtualenv中完成以下任务:
pip install pillow
pip install pycrypto
And then I installed libxml2-dev
and libxslt1-dev
via Synaptic and could accomplish the following:
然后我通过Synaptic安装libxml2-dev和libxslt1-dev,可以完成以下操作:
pip install lxml
I also did this so that the pymongo install didn't have any errors:
我也这样做了,所以pymongo安装没有任何错误:
pip uninstall pymongo
pip install pymongo # i defined the version i needed ie pip install pymongo==2.6.2
I'm still confused how this fixes the problem, because I thought virtualenv
was an isolated environment. Any clarification about this appreciated.
我仍然搞不清楚这是如何解决问题的,因为我认为virtualenv是一个孤立的环境。对此有任何的澄清。
#3
5
Work for me :
Just install python2.7-dev first sudo apt-get install python2.7-dev
为我工作:安装python2.7-dev first sudo apt-get安装python2.7-dev。
#4
2
In Ubuntu 16.04.1 this worked for me:
在Ubuntu 16.04.1中,这对我有用:
sudo apt-get install libxml2-dev libxslt1-dev python-dev
#5
1
For me the installation of lxml was failing on compilation. I followed the instructions for installation of lxml and reduced the compiler optimizations:
对我来说,lxml的安装失败了。我遵循了lxml的安装说明,并减少了编译器的优化:
sudo CFLAGS="-O0" pip install lxml
After doing this, the compile of lxml succeeded.
这样做之后,lxml的编译成功了。
#6
0
This can be a problem in the pip. To solve, try:
这可能是pip中的一个问题。尝试解决:
sudo apt-get remove python-pip
sudo apt-get删除python-pip
To install pip, securely download get-pip.py.
安装pip,安全下载get-pip.py。
https://bootstrap.pypa.io/get-pip.py
https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo python get-pip.py
#7
0
The cffi
library needs libffi-dev
:
cffi图书馆需要libf -dev:
sudo apt-get install libffi libffi-dev
#8
0
Easiest way is:
简单的方法是:
sudo apt-get build-dep python-imaging
and then
然后
pip install pillow
#9
0
This works for me, 12.04, python2.7.6 for package lxml
这对我来说,12.04,python2.7.6包装lxml。
sudo pip install libxml2 libxml2-dev libxslt1-dev
sudo pip install lxml