Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got an pkg_resources.DistributionNotFound error #10

Open
nicksspirit opened this issue Jan 17, 2018 · 7 comments
Open

Got an pkg_resources.DistributionNotFound error #10

nicksspirit opened this issue Jan 17, 2018 · 7 comments

Comments

@nicksspirit
Copy link

I installed pip-autoremove in my python 2.7 environment and as I was trying to pip-autoremove flake8 I got this traceback error:

Traceback (most recent call last): File "/usr/local/bin/pip-autoremove", line 11, in <module> sys.exit(main()) File "/Library/Python/2.7/site-packages/pip_autoremove.py", line 109, in main autoremove(args, yes=opts.yes) File "/Library/Python/2.7/site-packages/pip_autoremove.py", line 21, in autoremove dead = list_dead(names) File "/Library/Python/2.7/site-packages/pip_autoremove.py", line 29, in list_dead graph = get_graph() File "/Library/Python/2.7/site-packages/pip_autoremove.py", line 92, in get_graph for req in requires(dist): File "/Library/Python/2.7/site-packages/pip_autoremove.py", line 98, in requires return map(get_distribution, dist.requires()) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 558, in get_distribution dist = get_provider(dist) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 438, in get_provider return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 959, in require needed = self.resolve(parse_requirements(requirements)) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 846, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'tornado' distribution was not found and is required by the application

@jorgeorpinel
Copy link

jorgeorpinel commented Mar 6, 2018

Yes, I get this too... Not working! (Mac OS 10.13.3 with stock Python 2.7.10)

$ pip install --user pip-autoremove
Collecting pip-autoremove
  Using cached pip_autoremove-0.9.0-py2.py3-none-any.whl
Installing collected packages: pip-autoremove
Successfully installed pip-autoremove-0.9.0

$ pip show pip-autoremove
Name: pip-autoremove
Version: 0.9.0
Summary: Remove a package and its unused dependencies
Home-page: https://github.com/invl/pip-autoremove
Author: UNKNOWN
Author-email: UNKNOWN
License: Apache License 2.0
Location: /Users/drbidibombom/Library/Python/2.7/lib/python/site-packages
Requires: 

$ pip-autoremove -l
Traceback (most recent call last):
  File "/Users/drbidibombom/Library/Python/2.7/bin/pip-autoremove", line 11, in <module>
    sys.exit(main())
  File "/Users/drbidibombom/Library/Python/2.7/lib/python/site-packages/pip_autoremove.py", line 107, in main
    list_dead(args)
  File "/Users/drbidibombom/Library/Python/2.7/lib/python/site-packages/pip_autoremove.py", line 29, in list_dead
    graph = get_graph()
  File "/Users/drbidibombom/Library/Python/2.7/lib/python/site-packages/pip_autoremove.py", line 92, in get_graph
    for req in requires(dist):
  File "/Users/drbidibombom/Library/Python/2.7/lib/python/site-packages/pip_autoremove.py", line 98, in requires
    return map(get_distribution, dist.requires())
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 564, in get_distribution
    dist = get_provider(dist)
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 436, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 984, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 870, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'tornado' distribution was not found and is required by the application

UPDATE

You just need to pip install tornado ! (In my case I used pip install --user tornado.)

@jorgeorpinel
Copy link

jorgeorpinel commented Mar 6, 2018

After using this package to autoremove awscli, I also had pkg_resources.DistributionNotFound errors for jmespath<1.0.0,>=0.7.1 and docutils>=0.10, which I had to install manually for pip-autoremove to run again.

It seems the developers didn't configure the package correctly so pip is not installing or registering it's dependencies. So far we know at least of those 3 (tornado, jmespath, docutils).

@nicksspirit
Copy link
Author

So wait you are telling me that I have to install tornado for the pkg_resources.DistributionNotFound error to go away

tresni added a commit to tresni/pip-autoremove that referenced this issue May 1, 2018
These are due to packages being upgraded beyond what some depending package specifies (e.g. if you tend to do `pip list --outdated | xargs pip install --upgrade` or anything similar.)
To deal with this, we ignore version requirement if VersionConflict.

Not sure how we can end up in a DistributionNotFound scenario, but plenty of bug reports about it, so just ignoring those outright.

Fixes invl#7, invl#9, invl#10, invl#11.
tresni added a commit to tresni/pip-autoremove that referenced this issue May 1, 2018
These are due to packages being upgraded beyond what some depending package specifies (e.g. if you tend to do `pip list --outdated | xargs pip install --upgrade` or anything similar.)
To deal with this, we ignore version requirement if VersionConflict.

Not sure how we can end up in a DistributionNotFound scenario, but plenty of bug reports about it, so just ignoring those outright.

Fixes invl#7, invl#9, invl#10, invl#11.
tresni added a commit to tresni/pip-autoremove that referenced this issue May 1, 2018
These are due to packages being upgraded beyond what some depending package specifies (e.g. if you tend to do `pip list --outdated | xargs pip install --upgrade` or anything similar.)
To deal with this, we ignore version requirement if VersionConflict.

Not sure how we can end up in a DistributionNotFound scenario, but plenty of bug reports about it, so just ignoring those outright.

Fixes invl#7, invl#9, invl#10.
tresni added a commit to tresni/pip-autoremove that referenced this issue May 1, 2018
These are due to packages being upgraded beyond what some depending package specifies (e.g. if you tend to do `pip list --outdated | xargs pip install --upgrade` or anything similar.)
To deal with this, we ignore version requirement if VersionConflict.

Not sure how we can end up in a DistributionNotFound scenario, but plenty of bug reports about it, so just ignoring those outright.

Fixes invl#7, invl#9, invl#10.
@jaraco
Copy link

jaraco commented Aug 13, 2019

pkg_resources is known to do some unfriendly things when it comes to dependency resolution, especially if there are gaps in the dependency tree. Here's the error I encountered when trying to autoremove something, even though pipdeptree indicates that the missing dependency is missing from an unrelated package:

setuptools master $ pip-autoremove lpaste                                                                                                    
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pip-autoremove", line 10, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_autoremove.py", line 106, in main
    autoremove(args, yes=opts.yes)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_autoremove.py", line 21, in autoremove
    dead = list_dead(names)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_autoremove.py", line 29, in list_dead
    graph = get_graph()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_autoremove.py", line 89, in get_graph
    for req in requires(dist):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 481, in get_distribution
    dist = get_provider(dist)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 357, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'userpath' distribution was not found and is required by the application

Perhaps the best recommendation here would be not to use pkg_resources, but instead use importlib_metadata, which avoids enumerating the whole environment when finding package metadata.

@jaraco
Copy link

jaraco commented Aug 13, 2019

It seems the developers didn't configure the package correctly.

I don't believe this is the issue. I suspect one can replicate the issue by installing some package (with dependencies), uninstalling one of the dependencies on that package, and then trying to run pip-autoremove.

@otavio-silva
Copy link

Did anyone find out a solution for this?

tresni added a commit to tresni/pip-autoremove that referenced this issue Apr 11, 2020
These are due to packages being upgraded beyond what some depending package specifies (e.g. if you tend to do `pip list --outdated | xargs pip install --upgrade` or anything similar.)
To deal with this, we ignore version requirement if VersionConflict.

Not sure how we can end up in a DistributionNotFound scenario, but plenty of bug reports about it, so just ignoring those outright.

Fixes invl#7, invl#9, invl#10.
@tresni
Copy link
Contributor

tresni commented Sep 17, 2021

Should be addressed by the merge of #42 and the new release, please close if that resolves your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants