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

# pip install docker-registry

解决 error: command 'swig' failed with exit status 1_第1张图片

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

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

    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.

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

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

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

# ls /usr/include/openssl/

opensslconf-x86_64.h  opensslconf.h

文件都是存在的。看一下哪个文件报的错,/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

问题解决

你可能感兴趣的:(解决 error: command 'swig' failed with exit status 1)