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

 mobiledu2502859097 发布于 2022-12-09 17:17

环境:Linux Mint 17 Cinnamon.

显示此错误:

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

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

pip install lxml
pip install pillow
pip install pycrypto
pip install pymongo (fails but still shows in pip freeze)

这里有几个解决方案建议安装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

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

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

3 个回答
  • 为我工作:
    首先安装python2.7-dev
    sudo apt-get install python2.7-dev

    2022-12-11 02:09 回答
  • python2.7-dev通过Linux Mint 17中的Synaptic Package Manager 安装.

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

    pip install pillow
    pip install pycrypto
    

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

    pip install lxml
    

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

    pip uninstall pymongo
    pip install pymongo  # i defined the version i needed ie pip install pymongo==2.6.2
    

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

    2022-12-11 02:10 回答
  • 大多数情况下,这些是依赖性问题.

    在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
    

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

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

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

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

      使用您的发行包管理工具安装所需的包:例如,对于Ubuntu:

      aptitude install libssl-dev

      在你的virtualenv中重试pip:

      pip install requests[security]

    2022-12-11 03:11 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有