文档

在Linux系统的ECS实例中安装阿里云SDK失败怎么办?

更新时间:

本文介绍在Linux系统的ECS实例中安装阿里云SDK失败的解决方案。

说明

关于阿里云SDK更多信息,请参见SDK概述

问题现象

在Linux系统的ECS实例中,安装阿里云CLI工具成功后,使用pip install aliyun-python-sdk-slb命令安装阿里云SDK失败,报错信息类似如下所示。

pip install aliyun-python-sdk-slb
    src/hash_template.c:356: warning: implicit declaration of function ‘PyModule_GetDict’
    src/hash_template.c:356: warning: implicit declaration of function ‘Py_DECREF’
    src/hash_template.c:360: warning: implicit declaration of function ‘PyErr_Occurred’
    src/hash_template.c:361: warning: implicit declaration of function ‘Py_FatalError’
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-RtPfzh/pycrypto/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-sON4x0-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-RtPfzh/pycrypto/

问题原因

可能是由于Linux系统的ECS实例中部分Python文件缺失,导致安装阿里云SDK失败。

解决方案

请参考以下操作排查Python文件缺失情况并修复。

  1. 远程连接ECS实例。

    具体操作,请参见连接方式概述

  2. 执行如下命令,检查安装的python包。

    rpm -qa|grep python

    系统返回类似如下,发现缺少python-devel包。

    python-libs-2.6.6-52.el6.x86_64 libproxy-python-0.3.0-4.el6_3.x86_64 newt-python-0.52.11-3.el6.x86_64 python-ethtool-0.6-5.el6.x86_64 python-urlgrabber-3.9.1-9.el6.noarch python-iniparse-0.3.1-2.1.el6.noarch abrt-addon-python-2.0.8-21.el6.centos.x86_64 python-setuptools-0.6.10-3.el6.noarch python-iwlib-0.1-1.2.el6.x86_64 python-argparse-1.2.1-2.1.el6.noarch python-pycurl-7.19.0-8.el6.x86_64 python-2.6.6-52.el6.x86_64 libxml2-python-2.7.6-21.el6_8.1.x86_64 dbus-python-0.83.0-6.1.el6.x86_64 libreport-python-2.0.9-19.el6.centos.x86_64 python-pip-7.1.0-1.el6.noarch rpm-python-4.8.0-37.el6.x86_64
  3. 执行如下命令,安装python-devel包。

    说明

    CentOS 6与CentOS 8操作系统版本结束了生命周期(EOL),按照社区规则,CentOS 6/8的源地址内容已移除。当您在CentOS 6/8系统内继续使用默认配置的源地址时会发生报错。建议您先切换CentOS 6/8的源地址,然后再进行操作。具体操作,请参见 CentOS 6 EOL如何切换源?CentOS 8 EOL如何切换源?

    yum install python-devel
  4. 重新执行以下命令安装阿里云SDK,若不再提示以上报错信息,则表示问题已修复。

    pip install aliyun-python-sdk-slb
  • 本页导读 (1)
文档反馈