Python下Pipインストールパッケージ下のAttributeError:'Requirement'object has no attribute'project_name'

5335 ワード

引用:pipベースのサードパーティ依存ライブラリのインストール中にAttributeError:'Requirement'object has no attribute'project_name'のエラーメッセージ、この問題はどのように解決しますか?
1.質問の提出
あるオープンソースシステムのデバッグでは、requirementsを使用する依存パッケージをインストールする必要があります.txtは、以下のように、すべての依存パケットを記述する.
...................
HTTPReplay==0.1.5
idna==2.0
ipaddress==1.0.14
itsdangerous==0.24
Jinja2==2.8
jsbeautifier==1.5.10
Mako==1.0.1
MarkupSafe==0.23
ndg-httpsclient==0.4.0
pyasn1==0.1.8
pycparser==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_name
AttributeError: '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.0
The 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_name
AttributeError: 'Requirement' object has no attribute 'project_name'

問題は依然として存在し、このインストールパッケージに問題があるようです.バージョンが古いからではないでしょうか.次に試行を続行します.
 >>  sudo pip install six
polo@polo-notebook:/opt/cuckoo$ sudo pip install six
The 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-packages
You 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.0
Name: six
Version: 1.10.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: [email protected]
Installer: pip
License: MIT
Location: /usr/local/lib/python2.7/dist-packages
Requires: 
Classifiers:
  Programming Language :: Python :: 2
  Programming Language :: Python :: 3
  Intended Audience :: Developers
  License :: OSI Approved :: MIT License
  Topic :: Software Development :: Libraries
  Topic :: Utilities
You 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の問題はしばしば発生し、ほとんどの場合、バージョンの互換性の問題によるものであり、特に第三者プロジェクトが特定のバージョンの依存パッケージを強調している場合、現在のバージョンをアンインストールすることで、必要なバージョンをインストールすることもできます.しかし、これは私たちのシステムにいくつかの隠れた問題をもたらし、低バージョンのインストールパッケージと現在のシステムの他のバージョンの互換性の問題です.