解决 error: command 'swig' failed with exit status 1

# pip install docker-registry python


分析:观察出现的错误,发现最开始报错的地方提示不能找到openssl.h头文件。通常.h头文件都是放到/usr/inclue目录下的,并且头文件所在的安装包通常叫openssl-devel sql

解决办法:使用yum install openssl-devel安装openssl的头文件,成功后从新执行pip install docker-registry。又出现了下面的错误 docker

    running build_ext
    building 'M2Crypto.__m2crypto' extension
    swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
    swig -python -I/usr/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
    /usr/include/openssl/opensslconf.h:36: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing.
    error: command 'swig' failed with exit status 1
架构

即“/usr/include/openssl/opensslconf.h:36: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing. python2.7

网上说的,从新安装m2crypto,先卸载系统中已经安装的m2crypto再用pip安装的方法都是没有用的。 ui

解决办法:这个提示大意是说openssl-devel版本不适合你的系统架构,也就是x86的去找x86的头文件,x86_64的去找x86_64文件,但如今是互相找不到对方。 spa

查看一下安装的文件是否x86x64位的头文件都有 sqlalchemy

# ls /usr/include/openssl/ ip

opensslconf-x86_64.h  opensslconf.h ssl

文件都是存在的。看一下哪一个文件报的错,/usr/include/openssl/opensslconf.h:36,第36行报错,打开这个文件

#include "opensslconf-sparc.h"

#elif defined(__x86_64__)

#include "opensslconf-x86_64.h"    #原来是这样写的,说明默认去找x86_64位的头文件

#else

#error "This openssl-devel package does not work your architecture?"

#endif

 

#undef openssl_opensslconf_multilib_redirection_h

默认去找x86_64位的头文件报了错,那就说明但愿去找x86的文件了,修改方法以下

#include "opensslconf-sparc.h"

#elif defined(__x86_64__)

#include "opensslconf-x86_64.h"

#else

#include "opensslconf.h"     #去掉了原来的error提示,改为了安装opensslconf.h文件。

#endif

 

#undef openssl_opensslconf_multilib_redirection_h

再次执行pip install docker-registry

……

Successfully installed M2Crypto-0.22.3 docker-registry-0.9.1 sqlalchemy-0.9.4

问题解决

相关文章
相关标签/搜索