导入成功时pkg_resources.get_distribution()失败

时间:2019-04-01 16:57:30

标签: python package conda

我正在测试Python安装。我找到了两个sqlite3graph_tool软件包,它们可以import发出,但它们却从DistributionNotFound发出了pkg_resources错误(请参阅下面的控制台日志) )。

pkg_resources的确切功能是什么,怎么会丢失已安装的模块?

控制台日志:

>>> import pkg_resources
>>> import graph_tool
>>> pkg_resources.get_distribution("graph_tool")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 481, in get_distribution
    dist = get_provider(dist)
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 357, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'graph_tool' distribution was not found and is required by the application

>>> import sqlite3
>>> pkg_resources.get_distribution("sqlite3")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 481, in get_distribution
    dist = get_provider(dist)
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 357, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/anaconda/envs/py36/lib/python3.6/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'sqlite3' distribution was not found and is required by the application

0 个答案:

没有答案