Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip is giving conflict error while installing package

Tags:

python

pip

While running $ pip install <package>, I am getting below error, in this case I am installing PyJWT and also checked for other packages to crosscheck. This happened after upgrading pip to 19.0.2 from 19.0.1.

Check below errors while running pip install PyJWT, requirement are already satisfied, but still I am getting error, please suggest how to fix it.

$ easy_install pip 

for reinstalling the 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))
like image 463
tejesh Avatar asked Feb 15 '19 09:02

tejesh


People also ask

How do you resolve conflicts in pip?

Unfortunately, pip makes no attempt to resolve dependency conflicts. For example, if you install two packages, package A may require a different version of a dependency than package B requires. Pip can install from either Source Distributions (sdist) or Wheel (. whl) files.

Why pip is not working in Terminal?

Sometimes when you are installing packages, you might face the error: pip: command not found . This error could be due to the following reasons: Pip is not installed. Pip is installed, but it is not compatible with the current environment.


Video Answer


3 Answers

Seems like your problem is similar or the same as this bug which was ironically fixed in 19.0.2. The problem is somewhere along the line you tried to install a module and it failed. pip didn't properly clean up after itself and left a package in a broken state.

The solution seems to be to find any directories starting with - in your site-packages directory (/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages in your case) and rename them to what they should be. eg. if you find -yJWT-1.0.dist-info then you should rename it to PyJWT-1.0.dist-info. If you're not sure what it's real name should be then look for the Name value in -yJWT-1.0.dist-info/METADATA. NB. I just used PyJWT as an example, it might not be the package(s) that is/are broken. After that pip should be able to get up and running again.

like image 127
Dunes Avatar answered Nov 03 '22 13:11

Dunes


You could try to install the package pip-conflict-checker:

pip install pip-conflict-checker

and then run the command:

pipconflictchecker

this will show you the packages that cause troubles

like image 32
matyas Avatar answered Nov 03 '22 12:11

matyas


Complementary finding: Using @Dunes answer, couldn't fix the file name so I ended-up unninstalling every package from PIP

PowerShell pip uninstall -y (pip freeze)

When the loop broke on the Plackage "Plotly" I found the culprit.

like image 44
Adav Avatar answered Nov 03 '22 13:11

Adav