Python下Pip安装包下的AttributeError: 'Requirement' object has no attribute 'project_name'
来源:互联网 发布:遗传算法原理与应用 编辑:程序博客网 时间:2024/06/01 09:57
引言: 在基于pip安装第三方依赖库的过程中,会碰到AttributeError: 'Requirement' object has no attribute 'project_name'的错误信息,这个问题该如何解决呢?
1. 问题的提出
在某开源系统的调试中,需要安装一批依赖包,其使用一个requirements.txt来描述其所有的依赖包,具体如下:
...................HTTPReplay==0.1.5idna==2.0ipaddress==1.0.14itsdangerous==0.24Jinja2==2.8jsbeautifier==1.5.10Mako==1.0.1MarkupSafe==0.23ndg-httpsclient==0.4.0pyasn1==0.1.8pycparser==2.14.................................基于pip进行安装:
sudo pip install -r requirements.txt在安装过程中,出现来如下错误信息:
Exception:Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 317, in run requirement_set.prepare_files(finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 448, in _prepare_file req_to_install, finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 387, in _check_skip_installed req_to_install.check_if_exists() File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 1011, in check_if_exists self.req.project_nameAttributeError: 'Requirement' object has no attribute 'project_name'
2.问题的分析
第一步首先单独进行安装特定包的检查:
>> sudo pip install six==1.9.0
polo@polo-notebook:/opt/cuckoo$ sudo pip install six==1.9.0The directory '/home/polo/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.The directory '/home/polo/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.Exception:Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 317, in run requirement_set.prepare_files(finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 448, in _prepare_file req_to_install, finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 387, in _check_skip_installed req_to_install.check_if_exists() File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 1011, in check_if_exists self.req.project_nameAttributeError: 'Requirement' object has no attribute 'project_name'
问题依然存在,看来问题就出在这个安装包这里。是否是由于版本太老呢?接下来继续尝试。
>> sudo pip install six
polo@polo-notebook:/opt/cuckoo$ sudo pip install sixThe directory '/home/polo/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.The directory '/home/polo/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python2.7/dist-packagesYou are using pip version 8.1.1, however version 8.1.2 is available.You should consider upgrading via the 'pip install --upgrade pip' command.这里反馈的信息是six包已经被安装过了,难道是由于系统已经安装的six版本不兼容问题?
让我们来查看一下six当下的版本:
polo@polo-notebook:/opt/cuckoo$ pip show six---Metadata-Version: 2.0Name: sixVersion: 1.10.0Summary: Python 2 and 3 compatibility utilitiesHome-page: http://pypi.python.org/pypi/six/Author: Benjamin PetersonAuthor-email: benjamin@python.orgInstaller: pipLicense: MITLocation: /usr/local/lib/python2.7/dist-packagesRequires: Classifiers: Programming Language :: Python :: 2 Programming Language :: Python :: 3 Intended Audience :: Developers License :: OSI Approved :: MIT License Topic :: Software Development :: Libraries Topic :: UtilitiesYou are using pip version 8.1.1, however version 8.1.2 is available.You should consider upgrading via the 'pip install --upgrade pip' command.原来的确如此,要安装的版本低于目前系统的版本,故爆出来了如此诡异的错误信息。
3. 总结
在pip管理下的包在升级和安装过程中,project_name的问题时常发生,大部分的情况下都是版本的不兼容问题造成的,尤其在第三方项目强调特定版本的依赖包情况下,也可以通过卸载当下版本,安装需要的版本;但是这样也给我们的系统带来来若干隐患问题,低版本的安装包与当下系统中其他版本的兼容问题。
0 0
- Python下Pip安装包下的AttributeError: 'Requirement' object has no attribute 'project_name'
- python 使用 pip 安装 三方库的时候报错 “AttributeError: '_socketobject' object has no attribute...”
- AttributeError: '_Screen' object has no attribute 'onkeypress' python 的例子
- Python3下AttributeError: 'dict' object has no attribute 'iteritems'的问题分析
- Python3下AttributeError: 'dict' object has no attribute 'iteritems'的问题分析
- Python3.6 下yield的常见错误(AttributeError: 'generator' object has no attribute 'next')
- Debian (Jessie 8.0) 的修复pip AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'
- python __def__ Exception AttributeError: "'NoneType' object has no attribute
- python __def__ Exception AttributeError: "'NoneType' object has no attribute
- [Python][转]Exception AttributeError: "'NoneType' object has no attribute
- Python:AttributeError: 'function' object has no attribute '_doc_'
- [Python]attributeError:'module' object has no attribute 'dump'
- [python错误]builtins.AttributeError: 'module' object has no attribute 'request'
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- python AttributeError: 'module' object has no attribute 'setdefaultencoding'
- [python]Django AttributeError 'tuple' object has no attribute 'regex'
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- python AttributeError: 'module' object has no attribute 'dumps'解决办法
- RandomAccessFile 基础
- Xcode模拟器不显示iOS版本
- 【演歌】加賀の女 歌词翻译
- 19. Remove Nth Node From End of List
- bzoj2152(树形dp或点分治)
- Python下Pip安装包下的AttributeError: 'Requirement' object has no attribute 'project_name'
- C++安全函数之strcat_s
- 【容斥原理】
- 在shell下编译c与c++
- Redis和Memcached的区别
- 安卓的图片三级缓存
- 操作系统基础
- synchronized 修饰词用法总结。
- 21. Merge Two Sorted Lists