"错误:命令'x86_64-linux-gnu-gcc'以退出状态1失败"在virtualenv中

use*_*287 25 pip virtualenv linux-mint python-2.7

环境:Linux Mint 17 Cinnamon.

显示此错误:

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

在以下情况下尝试以下内容时virtualenv:

pip install lxml
pip install pillow
pip install pycrypto
pip install pymongo (fails but still shows in pip freeze)
Run Code Online (Sandbox Code Playgroud)

这里有几个解决方案建议安装python2.7-dev:

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

通过pip安装错误在virtualenv中安装lxml:命令'x86_64-linux-gnu-gcc'失败

枕头安装错误:命令'gcc'失败,退出状态为1

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

我对这个建议很困惑,因为我的理解是使用类似的东西:

sudo apt-get install python2.7-dev
Run Code Online (Sandbox Code Playgroud)

将它添加到Python的main*system*实例中,而不是将其添加到Python中virtualenv.(见 - https://unix.stackexchange.com/a/56392/92486)

我可以python2.7-dev只添加到virtualenvPython 的版本吗?

小智 20

大多数情况下,这些是依赖性问题.

在gcc编译器的堆栈跟踪之后,可以看到丢失的文件.有时安装Python开发包是不够的.

例如:我试图pip install requests[security]在我的virtualenv foo中做.这是pip-installer给我的结果.

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
Run Code Online (Sandbox Code Playgroud)

重要的是: #include <openssl/aes.h>

编译器非常清楚它要求这个文件 - 但它不存在于文件系统中.

知道了,剩下要做的就是:安装所需的库!

  1. 找出您的发行版所需的软件包:例如,对于Ubuntu,您可以访问Ubuntu软件包搜索站点并输入您要查找的丢失文件.在这种情况下" aes.h "
  2. 使用您的发行包管理工具安装所需的包:例如,对于Ubuntu:

    aptitude install libssl-dev

  3. 在你的virtualenv中重试pip:

    pip install requests[security]

  • 是! `install libssl-dev`在尝试安装bpython时解决了我的问题,这是一个全新的Ubuntu 14.04盒子.太感谢了! (2认同)

use*_*287 16

python2.7-dev通过Linux Mint 17中的Synaptic Package Manager 安装.

然后我可以完成以下任务virtualenv:

pip install pillow
pip install pycrypto
Run Code Online (Sandbox Code Playgroud)

然后我通过Synaptic 安装libxml2-devlibxslt1-dev完成以下操作:

pip install lxml
Run Code Online (Sandbox Code Playgroud)

我也这样做,以便pymongo安装没有任何错误:

pip uninstall pymongo
pip install pymongo  # i defined the version i needed ie pip install pymongo==2.6.2
Run Code Online (Sandbox Code Playgroud)

我仍然很困惑这是如何解决问题的,因为我认为这virtualenv是一个孤立的环境.任何关于此的澄清都表示赞赏.

  • 这适用于Ubuntu 14.10!非常感谢@ user1063287,你节省了我的一天!:) (2认同)
  • 对于'枕头'你还需要`sudo apt-get install build-essential libjpeg-dev libzlib-dev` (2认同)

Grv*_*agi 5

为我工作:
首先安装python2.7-dev
sudo apt-get install python2.7-dev