ImportError:没有名为'pkg'的模块_资源外部六.moves';'包_资源外部六'不是一个软件包

2024-06-08 04:12:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法导入pkg_资源。每当我试着看的时候

Python 3.5.2 (default, Jun 28 2016, 08:46:01) 
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> import pkg_resources
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 47, in <module>
      from pkg_resources.extern.six.moves import urllib, map, filter
ImportError: No module named 'pkg_resources.extern.six.moves'; 'pkg_resources.extern.six' is not a package

from pkg_resources引用/usr/lib/python3.5/site-packages/pkg_resources/extern(其中没有六个包)。你能指出我做错了什么吗?在

我使用的是ArchLinux,Python3.5.2


Tags: infromimportlibpackagesusrlinesite
1条回答
网友
1楼 · 发布于 2024-06-08 04:12:15

好吧,那里没有six包。six只是在中定义的名称

/usr/lib/python3.5/site-packages/pkg_resources/extern/__init__.py

确切地说,它看起来如下:

^{pr2}$

但是VendorImporterpython的一部分,它是{}的一部分,所以我想这是可以预料的。简单地说,它从以下位置执行导入:

/usr/lib/python3.5/site-packages/six.py

其中包含moves好的:

_MovedItems._moved_attributes = _moved_attributes

moves = _MovedItems(__name__ + ".moves")
_importer._add_module(moves, "moves")

现在让我们看看pacman是如何处理的:

# pacman -Qo /usr/lib/python3.5/site-packages/pkg_resources/extern/__init__.py
/usr/lib/python3.5/site-packages/pkg_resources/extern/__init__.py is owned by python-setuptools 1:25.1.3-1

对,extern/__init__.pysetuptools所有,这就是我们所期望的。现在

# pacman -Qo /usr/lib/python3.5/site-packages/six.py
/usr/lib/python3.5/site-packages/six.py is owned by python-six 1.10.0-2

我们看到sixpython-six的一部分。在

因此,我们发现python-setuptools依赖于{}。因此,^{} dependency chain是不正确的,因为它没有列出python-six,这是包管理器有时会发生的事情(不仅是pacman,而且所有包管理器都会时不时地遇到依赖链的问题)。在

对于手头的问题,您需要手动安装python-six,然后{}将按预期工作:

pacman -S python-six

相关问题 更多 >

    热门问题