pip在安装软件包时给出了冲突错误

时间:2019-02-15 09:37:49

标签: python pip

运行$ pip install <package>时,出现以下错误,在这种情况下,我正在安装PyJWT,还检查了其他要交叉检查的软件包。这是在将点值从19.0.1升级到19.0.2后发生的。

在运行pip install PyJWT时检查以下错误,已经满足要求,但仍然出现错误,请提出解决方法。

$ easy_install pip 

用于重新安装点子。

$ pip install PyJWT

Tejeshs-MacBook-Air:selenium_testing tejeshagrawal$ pip install PyJWT
Requirement already satisfied: PyJWT in
/usr/local/lib/python3.7/site-packages (1.7.1) Error checking for
conflicts. Traceback (most recent call last):   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2897, in _dep_map
    return self.__dep_map   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2691, in __getattr__
    raise AttributeError(attr) AttributeError: _DistInfoDistribution__dep_map

**During handling of the above exception, another exception occurred:**

Traceback (most recent call last):   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2888, in _parsed_pkg_info
    return self._pkg_info   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2691, in __getattr__
    raise AttributeError(attr) AttributeError: _pkg_info

**During handling of the above exception, another exception occurred:**

Traceback (most recent call last):   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/commands/install.py",
line 503, in _warn_about_conflicts
    package_set, _dep_info = check_install_conflicts(to_install)   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/check.py",
line 108, in check_install_conflicts
    package_set, _ = create_package_set_from_installed()   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/check.py",
line 47, in create_package_set_from_installed
    package_set[name] = PackageDetails(dist.version, dist.requires())   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2635, in requires
    dm = self._dep_map   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2899, in _dep_map
    self.__dep_map = self._compute_dependencies()   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2908, in _compute_dependencies
    for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2890, in _parsed_pkg_info
    metadata = self.get_metadata(self.PKG_INFO)   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 1410, in get_metadata
    value = self._get(self._fn(self.egg_info, name))   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 1522, in _get
    with open(path, 'rb') as stream: FileNotFoundError: [Errno 2] No such file or directory:
'/usr/local/lib/python3.7/site-packages/~ip-18.1.dist-info/METADATA'
Tejeshs-MacBook-Air:selenium_testing tejeshagrawal$ pip freeze >
require.txt Could not parse requirement: -ip Exception: Traceback
(most recent call last):   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2584, in version
    return self._version   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2691, in __getattr__
    raise AttributeError(attr) AttributeError: _version

**During handling of the above exception, another exception occurred:**

Traceback (most recent call last):   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/base_command.py",
line 179, in main
    status = self.run(options, args)   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/commands/freeze.py",
line 93, in run
    for line in freeze(**freeze_kwargs):   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/freeze.py",
line 62, in freeze
    req = FrozenRequirement.from_dist(dist)   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/freeze.py",
line 239, in from_dist
    req = dist.as_requirement()   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2716, in as_requirement
    if isinstance(self.parsed_version, packaging.version.Version):   File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2551, in parsed_version
    self._parsed_version = parse_version(self.version)   File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2589, in version
    raise ValueError(tmpl % self.PKG_INFO, self) ValueError: ("Missing 'Version:' header and/or METADATA file", Unknown [unknown version]
(/usr/local/lib/python3.7/site-packages))

4 个答案:

答案 0 :(得分:6)

似乎您的问题与this bug相似或具有讽刺意味的fixed in 19.0.2相似。问题出在您尝试安装模块的过程中,但失败了。 phase-active自身没有正确清理后,使包装处于损坏状态。

解决方案似乎是在您的pip目录(以您的情况为-)中找到以site-packages开头的任何目录,并将其重命名为应有的目录。例如。如果找到/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages,则应将其重命名为-yJWT-1.0.dist-info。如果不确定真实名称是什么,请在PyJWT-1.0.dist-info中查找Name值。注意我仅以-yJWT-1.0.dist-info/METADATA为例,它可能不是被破坏的包装。之后,该pip应该可以重新启动并运行。

答案 1 :(得分:1)

您可以尝试安装软件包pip-conflict-checker:

pip install pip-conflict-checker

,然后运行命令:

pipconflictchecker

这将向您显示引起麻烦的软件包

答案 2 :(得分:0)

补充发现: 使用@Dunes答案,无法修复文件名,因此我最终从PIP卸载了每个软件包

PowerShell pip uninstall -y (pip freeze)

当“ Plotage”“情节”的循环中断时,我找到了罪魁祸首。

答案 3 :(得分:0)

您也可以通过以下链接创建虚拟环境:-https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands

    Step 1: conda create -n myenv python=3.7.4
    Step 2: conda activate myenv
    Step 3: pip install package_name

这有助于管理单个conda环境以管理软件包。

相关问题