Reputation: 125
I can not import pkg_resources. Whenever I tried it shows
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
Is from pkg_resources
referring to /usr/lib/python3.5/site-packages/pkg_resources/extern
(in which there is no six package). Can you point out what I am doing wrong?
I am using Arch Linux, Python 3.5.2
Upvotes: 1
Views: 14034
Reputation: 879
In my case I did followings:
1-step:
sudo apt update && sudo apt install --reinstall python3-certbot
python3-six
and
2-step:
sudo apt install --reinstall python3-acme python3-certifi python3-chardet python3-configargparse python3-configobj python3-cryptography python3-distro python3-future python3-idna python3-josepy python3-lib2to3 python3-minimal python3-openssl python3-parsedatetime python3-pkg-resources python3-requests python3-requests-toolbelt python3-rfc3339 python3-six python3-tz python3-urllib3 python3-zope.component python3-zope.event python3-zope.hookable python3-zope.interface
Upvotes: 1
Reputation: 3027
Well, there is no six
package there. six
is just a name defined in
/usr/lib/python3.5/site-packages/pkg_resources/extern/__init__.py
To be exact, it looks as follows:
names = 'packaging', 'pyparsing', 'six'
VendorImporter(__name__, names).install()
But VendorImporter
is a rather uncommon piece of python
, it is part of setuptools
therefore it can be expected, I guess. In simple words it performs the import from:
/usr/lib/python3.5/site-packages/six.py
Which does contain moves
alright:
_MovedItems._moved_attributes = _moved_attributes
moves = _MovedItems(__name__ + ".moves")
_importer._add_module(moves, "moves")
Now let's see how pacman
deals with that:
# 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
Right, extern/__init__.py
is owned by setuptools
, that is what we expected. Now
# 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
We see that six
is part of python-six
.
So, we discovered that python-setuptools
is dependent on python-six
. The python-setuptools
dependency chain is therefore incorrect since it does not list python-six
, that is something that happens sometimes with package managers (not only pacman
but all package managers suffer from problems with dependency chains from time to time).
For the problem at hand, you need to install python-six
manually, and python-setuptools
will then work as expected:
pacman -S python-six
Upvotes: 2