src/MD2.c:31:20: 错误:Python.h:没有那个文件或目录

本文转载:https://blog.csdn.net/duguduchong/article/details/8963608

一、前言

                  在CentOS 上安装fabric时出现问题,首先已安装pip, 用pip执行以下命令pip install

出现以下问题

    [niy@niy-computer /]$ sudo pip install fabric
    Requirement already satisfied (use --upgrade to upgrade): fabric in /usr/lib/python2.6/site-packages/Fabric-1.3.1-py2.6.egg
    Requirement already satisfied (use --upgrade to upgrade): ssh>=1.7.8 in /usr/lib/python2.6/site-packages/ssh-1.8.0-py2.6.egg (from fabric)
    Downloading/unpacking pycrypto>=2.1,!=2.4 (from ssh>=1.7.8->fabric)
      Running setup.py egg_info for package pycrypto
    Installing collected packages: pycrypto
      Found existing installation: pycrypto 2.0.1
        Uninstalling pycrypto:
          Successfully uninstalled pycrypto
      Running setup.py install for pycrypto
        warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
        building 'Crypto.Hash._MD2' extension
        gcc -pthread -fno-strict-aliasing -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.6 -c src/MD2.c -o build/temp.linux-i686-2.6/src/MD2.o
        src/MD2.c:31:20: 错误:Python.h:没有那个文件或目录
        src/MD2.c:131: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        In file included from src/MD2.c:147:
        src/hash_template.c:48: 错误:expected specifier-qualifier-list before ‘PyObject_HEAD’
        src/hash_template.c:59: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PyTypeObject’
        src/hash_template.c: 在函数‘newALGobject’中:
        src/hash_template.c:69: 警告:隐式声明函数‘PyObject_New’
        src/hash_template.c:69: 错误:expected expression before ‘ALGobject’
        src/hash_template.c: 在文件层:
        src/hash_template.c:76: 错误:expected ‘)’ before ‘*’ token
        src/hash_template.c:91: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        src/hash_template.c:110: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        src/hash_template.c:122: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        src/hash_template.c:162: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        src/hash_template.c:188: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        src/hash_template.c:190: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ALG_methods’
        src/hash_template.c:199: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        src/hash_template.c:225: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ALGtype’
        src/hash_template.c:271: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
        src/hash_template.c:304: 错误:数组元素的类型不完全
        src/hash_template.c:305: 错误:‘PyCFunction’未声明(不在函数内)
        src/hash_template.c:305: 错误:expected ‘}’ before ‘ALG_new’
        src/hash_template.c: 在函数‘init_MD2’中:
        src/hash_template.c:339: 错误:‘PyObject’未声明(在此函数内第一次使用)
        src/hash_template.c:339: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
        src/hash_template.c:339: 错误:所在的函数内也只报告一次。)
        src/hash_template.c:339: 错误:‘m’未声明(在此函数内第一次使用)
        src/hash_template.c:351: 错误:‘ALGtype’未声明(在此函数内第一次使用)
        src/hash_template.c:351: 错误:‘PyType_Type’未声明(在此函数内第一次使用)
        src/hash_template.c:352: 警告:隐式声明函数‘Py_InitModule’
        src/hash_template.c:356: 错误:‘o’未声明(在此函数内第一次使用)
        src/hash_template.c:356: 警告:隐式声明函数‘PyInt_FromLong’
        src/hash_template.c:356: 警告:隐式声明函数‘PyDict_SetItemString’
        src/hash_template.c:356: 警告:隐式声明函数‘PyModule_GetDict’
        src/hash_template.c:356: 警告:隐式声明函数‘Py_DECREF’
        src/hash_template.c:360: 警告:隐式声明函数‘PyErr_Occurred’
        src/hash_template.c:361: 警告:隐式声明函数‘Py_FatalError’
        error: command 'gcc' failed with exit status 1
        Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ai6cQR-record/install-record.txt --single-version-externally-managed:
        running install
     
    running build
     
    running build_py
     
    running build_ext
     
    running build_configure
     
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
     
    building 'Crypto.Hash._MD2' extension
     
    gcc -pthread -fno-strict-aliasing -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.6 -c src/MD2.c -o build/temp.linux-i686-2.6/src/MD2.o
     
    src/MD2.c:31:20: 错误:Python.h:没有那个文件或目录
     
    src/MD2.c:131: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    In file included from src/MD2.c:147:
     
    src/hash_template.c:48: 错误:expected specifier-qualifier-list before ‘PyObject_HEAD’
     
    src/hash_template.c:59: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PyTypeObject’
     
    src/hash_template.c: 在函数‘newALGobject’中:
     
    src/hash_template.c:69: 警告:隐式声明函数‘PyObject_New’
     
    src/hash_template.c:69: 错误:expected expression before ‘ALGobject’
     
    src/hash_template.c: 在文件层:
     
    src/hash_template.c:76: 错误:expected ‘)’ before ‘*’ token
     
    src/hash_template.c:91: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    src/hash_template.c:110: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    src/hash_template.c:122: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    src/hash_template.c:162: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    src/hash_template.c:188: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    src/hash_template.c:190: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ALG_methods’
     
    src/hash_template.c:199: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    src/hash_template.c:225: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ALGtype’
     
    src/hash_template.c:271: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
     
    src/hash_template.c:304: 错误:数组元素的类型不完全
     
    src/hash_template.c:305: 错误:‘PyCFunction’未声明(不在函数内)
     
    src/hash_template.c:305: 错误:expected ‘}’ before ‘ALG_new’
     
    src/hash_template.c: 在函数‘init_MD2’中:
     
    src/hash_template.c:339: 错误:‘PyObject’未声明(在此函数内第一次使用)
     
    src/hash_template.c:339: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
     
    src/hash_template.c:339: 错误:所在的函数内也只报告一次。)
     
    src/hash_template.c:339: 错误:‘m’未声明(在此函数内第一次使用)
     
    src/hash_template.c:351: 错误:‘ALGtype’未声明(在此函数内第一次使用)
     
    src/hash_template.c:351: 错误:‘PyType_Type’未声明(在此函数内第一次使用)
     
    src/hash_template.c:352: 警告:隐式声明函数‘Py_InitModule’
     
    src/hash_template.c:356: 错误:‘o’未声明(在此函数内第一次使用)
     
    src/hash_template.c:356: 警告:隐式声明函数‘PyInt_FromLong’
     
    src/hash_template.c:356: 警告:隐式声明函数‘PyDict_SetItemString’
     
    src/hash_template.c:356: 警告:隐式声明函数‘PyModule_GetDict’
     
    src/hash_template.c:356: 警告:隐式声明函数‘Py_DECREF’
     
    src/hash_template.c:360: 警告:隐式声明函数‘PyErr_Occurred’
     
    src/hash_template.c:361: 警告:隐式声明函数‘Py_FatalError’
     
    error: command 'gcc' failed with exit status 1
     
    ----------------------------------------
      Rolling back uninstall of pycrypto
    Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ai6cQR-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-root/pycrypto
    Storing complete log in /root/.pip/pip.log


二 解决方案

原因是少了python的dev

[niy@niy-computer /]$ sudo yum  install python-devel
————————————————
版权声明:本文为CSDN博主「duguduchong」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/duguduchong/article/details/8963608

<think>好的,我现在需要帮助用户解决执行`python setup.py bdist_wheel`失败的问题,特别是涉及Eigen和setuptools的错误,以及如何处理SetuptoolsDeprecationWarning。首先,我得理清用户的问题点。 用户提到了退出代码1,这通常意味着编译安装过程中出现了错误错误信息中提到了Eigen库,可能是在编译需要Eigen的C++扩展时,找不到头文件文件。另外,SetuptoolsDeprecationWarning提示用户使用了过时的参数,比如`description-file`,需要改为`description_file`。 首先,针对Eigen相关的问题,用户可能需要确保Eigen已经正确安装,并且系统能够找到它的路径。可能用户没有正确设置环境变量,比如EIGEN_INCLUDE_DIR,者在setup.py中没有正确配置include_dirs。这时候需要检查setup.py中的Extension部分,确保包含了Eigen的头文件路径。 然后是Setuptools的警告,这通常是因为旧版本的参数名被弃用,需要替换为新名称。例如,`description-file`应改为`description_file`,`setup_requires`可能需要替换为其他方式,比如使用pyproject.toml。用户需要更新他们的setup.pysetup.cfg中的参数,同时升级setuptools到最新版本以避免这些问题。 接下来,用户可能没有正确安装wheel包,导致无法生成wheel文件。需要确保wheel已安装,并且使用正确的构建命令,比如使用`python -m build`而不是直接运行setup.py。 另外,用户提到的Python.h缺失问题,这可能是因为缺少Python的开发头文件。在Windows上,可能需要安装Visual Studio Build Tools,并确保Python的开发部分已安装,而用户使用的是Embeddable版本,这可能缺少必要的头文件。所以建议用户安装完整版的Python者手动添加包含Python.h的路径。 最后,可能需要检查用户的编译环境,比如是否安装了正确的C++编译工具链,是否有权限问题,者路径中存在空格导致编译失败。综合这些因素,逐步排除可能的问题点,并给出相应的解决步骤。</think>关于执行$python\ setup.py\ bdist_wheel$失败的问题,以下是分步骤解决方案: ### 一、Eigen库相关编译错误解决方案 1. **验证Eigen安装路径** - 确保Eigen头文件路径已加入环境变量: ```bash export EIGEN_INCLUDE_DIR=/usr/local/include/eigen3 # Linux/Mac set EIGEN_INCLUDE_DIR=C:\Eigen # Windows ``` - 在$setup.py$中显式指定包含路径: ```python from setuptools import setup, Extension ext_modules = [ Extension('your_module', sources=['src/main.cpp'], include_dirs=[os.environ.get('EIGEN_INCLUDE_DIR')]) ] ``` 2. **使用CMake构建系统(推荐)** ```python # setup.py示例 from skbuild import setup setup( cmake_args=['-DEigen3_DIR=/path/to/eigen/share/eigen3/cmake'] ) ``` 需先安装$scikit-build$包:$pip install scikit-build$[^1] ### 二、SetuptoolsDeprecationWarning处理 1. **参数名更新** ```diff setup( - description_file="README.md", + long_description=open("README.md").read(), + long_description_content_type="text/markdown" ) ``` 2. **配置文件迁移(推荐方案)** 创建$pyproject.toml$: ```toml [build-system] requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" [project] name = "your_package" version = "0.1.0" description = "Your description" ``` 3. **升级构建工具** ```bash pip install --upgrade setuptools wheel pip ``` ### 三、Python.h缺失问题(Windows特例) 1. **安装完整Python发行版** - 从[python.org]下载安装时勾选"Install development headers" 2. **手动配置路径** ```python # setup.py中添加 import sys include_dirs = [ sysconfig.get_path('include'), sysconfig.get_path('include') + '\\..\\..\\PC' ] ``` ### 四、现代构建流程推荐 ```bash # 使用官方推荐构建方式 python -m pip install --upgrade build python -m build --wheel ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值