温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

openstack nova编译或打包rpm出现cannot import name integer_types报错的解决方法

发布时间:2021-12-06 14:06:47 来源:亿速云 阅读:205 作者:柒染 栏目:云计算

这期内容当中小编将会给大家带来有关openstack nova编译或打包rpm出现cannot import name integer_types报错的解决方法,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

通过rpmbuild打包nova时,出现了如下报错:

  File "/usr/lib/python2.7/site-packages/keystoneauth2/session.py", line 26, in <module>
    import requests
  File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 63, in <module>
    from . import utils
  File "/usr/lib/python2.7/site-packages/requests/utils.py", line 26, in <module>
    from .compat import (
ImportError: cannot import name integer_types

大致看了以下报错信息,应该是python的requests模块安装有问题,查看之前的依赖安装日志,出现过如下内容:

Failed:
  python2-requests.noarch 0:2.11.1-1.el7                                      python2-urllib3.noarch 0:1.16-1.el7

这两个模块安装失败,于是单独安装这两个模块,但是均报错

Downloading packages:
(1/2): python2-urllib3-1.16-1.el7.noarch.rpm                                                                                    | 126 kB  00:00:00     
(2/2): python2-requests-2.11.1-1.el7.noarch.rpm                                                                                 | 105 kB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                  190 kB/s | 231 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python2-urllib3-1.16-1.el7.noarch                                                                                                   1/2 
Error unpacking rpm package python2-urllib3-1.16-1.el7.noarch
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname: cpio: rename
  Installing : python2-requests-2.11.1-1.el7.noarch                                                                                                2/2 
Error unpacking rpm package python2-requests-2.11.1-1.el7.noarch
error: python2-urllib3-1.16-1.el7.noarch: install failed
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/requests/packages/chardet: cpio: rename
  Verifying  : python2-urllib3-1.16-1.el7.noarch                                                                                                   1/2 
  Verifying  : python2-requests-2.11.1-1.el7.noarch                                                                                                2/2 

Failed:
  python2-requests.noarch 0:2.11.1-1.el7                                      python2-urllib3.noarch 0:1.16-1.el7

应该是这两个模块已存在的版本有问题,于是将site-packages中的这两个模块的内容删除

[root@localhost site-packages]# rm -rf url
urlgrabber/                     urllib3/                        urllib3-1.21.dist-info/         
urlgrabber-3.10-py2.7.egg-info  urllib3-1.16-py2.7.egg-info/
[root@localhost site-packages]# rm -rf urllib3*

[root@localhost site-packages]# rm -rf requests
requests/                                requestsexceptions/                      requests_mock/
requests-2.11.1-py2.7.egg-info/          requestsexceptions-1.1.3-py2.7.egg-info/ requests_mock-1.3.0.dist-info/
requests-2.13.0.dist-info/               requestsexceptions-1.2.0.dist-info/      
[root@localhost site-packages]# rm -rf requests
[root@localhost site-packages]# rm -rf requests-*

再安装模块即可成功

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python2-urllib3-1.16-1.el7.noarch                                                                                                   1/2 
  Installing : python2-requests-2.11.1-1.el7.noarch                                                                                                2/2 
  Verifying  : python2-urllib3-1.16-1.el7.noarch                                                                                                   1/2 
  Verifying  : python2-requests-2.11.1-1.el7.noarch                                                                                                2/2 

Installed:
  python2-requests.noarch 0:2.11.1-1.el7                                                                                                               

Dependency Installed:
  python2-urllib3.noarch 0:1.16-1.el7                                                                                                                  

Complete!

再通过rpmbuild打包,就没有任何问题了。

上述就是小编为大家分享的openstack nova编译或打包rpm出现cannot import name integer_types报错的解决方法了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI