解决 error: command 'swig' failed with exit status 1
2019獨角獸企業重金招聘Python工程師標準>>>
# pip install docker-registry
分析:觀察出現的錯誤,發現最開始報錯的地方提示不能找到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文件,但現在是互相找不到對方。
查看一下安裝的文件是否x86和x64位的頭文件都有
# 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
問題解決
轉載于:https://my.oschina.net/lionel45/blog/664017
總結
以上是生活随笔為你收集整理的解决 error: command 'swig' failed with exit status 1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到母亲生孩子了是什么预兆
- 下一篇: hadoop 入门实例【转】