pypa / virtualenv

Virtual Python Environment builder
https://virtualenv.pypa.io
MIT License
4.83k stars 1.03k forks source link

"AttributeError: 'dict' object has no attribute 'select'" when running CLI commands #2174

Closed gabrielmip closed 3 years ago

gabrielmip commented 3 years ago

Hi there!

Issue

The CLI is raising exceptions at least when it is run without any parameters and with the --help parameter, but probably with other parameters too. Poetry reported the line number where the exception was raised:

Creating virtualenv worker-scheduler-dZdMRvTq-py3.9 in /home/gabriel/.cache/pypoetry/virtualenvs

  AttributeError

  'dict' object has no attribute 'select'

  at /usr/lib/python3.9/site-packages/virtualenv/run/plugin/base.py:14 in entry_points_for
      10│     _ENTRY_POINTS = None
      11│ 
      12│     @classmethod
      13│     def entry_points_for(cls, key):
    → 14│         return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(group=key))
      15│ 
      16│     @staticmethod
      17│     def entry_points():
      18│         if PluginLoader._ENTRY_POINTS is None:

To be clear, virtualenv still raises the exception when I run virtualenv directly, without poetry's interference.

Environment

Provide at least:

gaborbernat commented 3 years ago

This sounds like a problem of having an incorrect dependency of importlib-metadata. What python packages have you installed and how did you install those?

gabrielmip commented 3 years ago

I mostly install system-wide packages using the operational system's package manager, but, looking at the bash history, I have installed a bunch of other packages directly by pip:

ansible-lint
autopep8
cli_helpers
dephell
docker-compose
flake8
flake8 pylint
flower
ipython
jedi-language-server
mycli
neovim
pgcli
pyls-mypy
pymysql
pynvim
python-language-server[all]
six
sphinx
sphinxcontrib-httpdomain
sqlparse
whitenoise

The import-metadata version is 0.23. The complete output of pip list follows:

Package                       Version
----------------------------- -----------------
alabaster                     0.7.12
alembic                       1.3.1
amqp                          2.6.1
aniso8601                     8.0.0
ansible                       4.4.0
ansible-core                  2.11.4
ansible-lint                  5.1.2
anytree                       2.8.0
apipkg                        1.5
appdirs                       1.4.4
argcomplete                   1.12.1
argon2-cffi                   20.1.0
asn1crypto                    0.24.0
astroid                       2.5.1
async-generator               1.10
attrs                         19.3.0
autopep8                      1.5.5
awscli                        1.20.21
Babel                         2.9.1
backcall                      0.2.0
backports.csv                 1.0.7
bcrypt                        3.2.0
Beaker                        1.11.0
beancount                     2.3.4
beautifulsoup4                4.9.3
billiard                      3.6.3.0
bleach                        3.3.1
blessings                     1.7
blinker                       1.4
botocore                      1.21.21
bottle                        0.12.19
bpython                       0.21
bracex                        2.1.1
btrfsutil                     5.13.1
CacheControl                  0.12.6
cached-property               1.5.2
cachetools                    4.0.0
cachy                         0.3.0
celery                        4.4.7
ceph                          1.0.0
ceph-volume                   1.0.0
cephfs                        2.0.0
cephfs-shell                  0.0.1
certifi                       2019.9.11
cffi                          1.14.6
chardet                       4.0.0
cheroot                       8.5.2
cleo                          0.7.6
cli-helpers                   2.1.0
Click                         7.0
clikit                        0.6.2
colorama                      0.4.4
commonmark                    0.9.1
configobj                     5.1.0.dev0
contextlib2                   0.6.0.post1
crashtest                     0.3.1
cryptography                  2.1.4
curtsies                      0.3.5
cwcwidth                      0.1.4
cycler                        0.10.0
debugpy                       1.4.1
decorator                     5.0.9
defusedxml                    0.7.1
distlib                       0.3.2
distro                        1.5.0
dnspython                     1.16.0
docker                        5.0.0
docker-compose                1.29.2
docker-pycreds                0.4.0
dockerpty                     0.4.1
docopt                        0.6.2
docstring-to-markdown         0.7
docutils                      0.17.1
enrich                        1.2.6
entrypoints                   0.3
f.lux-indicator-applet        1.2.0
filelock                      3.0.12
flake8                        3.8.4
Flask                         1.1.1
Flask-Babel                   2.0.0
Flask-Cors                    3.0.8
Flask-HTTPAuth                3.3.0
Flask-RESTful                 0.3.7
flask-restplus                0.13.0
flower                        0.9.7
future                        0.18.2
google-api-core               2.0.0
google-api-python-client      2.18.0
google-auth                   1.11.0
google-auth-httplib2          0.1.0
googleapis-common-protos      1.53.0
greenlet                      1.1.1
html5lib                      1.1
httpie                        2.4.0
httplib2                      0.19.1
humanize                      3.1.0
idna                          2.6
imagesize                     1.2.0
importlib-metadata            0.23
iniconfig                     1.1.1
ipykernel                     6.0.3
ipython                       7.27.0
ipython-genutils              0.2.0
ipywidgets                    7.6.3
isc                           2.0
isort                         5.7.0
itsdangerous                  2.0.1
jaraco.classes                3.2.1
jaraco.collections            3.3.0
jaraco.functools              3.3.0
jaraco.itertools              6.0.1
jaraco.logging                3.1.0
jaraco.stream                 3.0.2
jaraco.text                   3.5.0
jedi                          0.17.2
jeepney                       0.7.1
Jinja2                        2.10.3
jmespath                      0.10.0
jsonschema                    3.2.0
jupyter-client                6.1.12
jupyter-console               6.4.0
jupyter-core                  4.7.1
jupyterlab-pygments           0.1.2
keyring                       10.6.0
keyrings.alt                  3.0
kiwisolver                    1.3.2
kombu                         4.6.11
lark-parser                   0.11.3
lazy-object-proxy             1.5.2
lensfun                       0.3.95
lightdm-gtk-greeter-settings  1.2.2
lit                           12.0.1.dev0
lockfile                      0.12.2
lxml                          4.6.3
Mako                          1.1.0
mallard-ducktype              1.0.2
Markdown                      3.3.4
markdown2                     2.4.0
MarkupSafe                    2.0.1
marshmallow                   3.2.2
matplotlib                    3.4.2
matplotlib-inline             0.1.2
mccabe                        0.6.1
meson                         0.59.1
mistune                       0.8.4
more-itertools                7.2.0
msgpack                       1.0.2
mycli                         1.22.2
mypy                          0.812
mypy-extensions               0.4.3
nbclient                      0.5.3
nbconvert                     6.1.0
nbformat                      5.1.3
neovim                        0.3.1
nest-asyncio                  1.5.1
notebook                      6.3.0
numpy                         1.20.3
ordered-set                   4.0.2
packaging                     20.9
pandocfilters                 1.4.3
paramiko                      2.7.2
parso                         0.7.1
passlib                       1.7.1
pastel                        0.2.0
pendulum                      2.1.2
pep517                        0.11.0
pexpect                       4.8.0
pgcli                         3.1.0
pgspecial                     1.11.10
pickleshare                   0.7.5
Pillow                        8.3.1
pip                           20.3.4
pkginfo                       1.7.1
platformdirs                  2.0.2
pluggy                        0.13.1
ply                           3.11
poetry                        1.1.8
poetry-core                   1.0.3
progress                      1.5
prometheus-client             0.8.0
prompt-toolkit                3.0.20
protobuf                      3.17.3
psutil                        5.8.0
psycopg2                      2.8.4
ptyprocess                    0.7.0
py                            1.10.0
pyaes                         1.6.1
pyaml                         21.8.3
pyasn1                        0.4.8
pyasn1-modules                0.2.8
pycairo                       1.20.0
pycodestyle                   2.6.0
pycparser                     2.20
pycrypto                      2.6.1
pydocstyle                    5.1.1
pyflakes                      2.2.0
pygls                         0.9.1
Pygments                      2.10.0
PyGObject                     3.40.1
pylev                         1.4.0
pylint                        2.7.2
pyls-mypy                     0.1.8
PyMySQL                       1.0.2
PyNaCl                        1.4.0
pynvim                        0.4.3
pyOpenSSL                     20.0.1
pyparsing                     2.4.7
pyparted                      3.11.7
pyperclip                     1.7.0
pyrsistent                    0.18.0
PySide2                       5.15.2
PySocks                       1.7.1
pytest                        6.2.4
python-dateutil               2.8.2
python-distutils-extra        2.39
python-dotenv                 0.19.0
python-editor                 1.0.4
python-jsonrpc-server         0.4.0
python-language-server        0.36.2
python-magic                  0.4.24
python-xapp                   2.2.1
python-xlib                   0.31
pytz                          2019.3
pytzdata                      2020.1
pyxdg                         0.27
PyYAML                        5.4.1
pyzmq                         22.2.1
rados                         2.0.0
ranger-fm                     1.9.3
rbd                           2.0.0
Reflector                     2021.7.8.19.52.52
requests                      2.26.0
requests-toolbelt             0.9.1
resolvelib                    0.5.5
retrying                      1.3.3
rgw                           2.0.0
rich                          10.7.0
rope                          0.18.0
rsa                           4.0
ruamel.yaml                   0.17.13
ruamel.yaml.clib              0.2.6
s3transfer                    0.5.0
SecretStorage                 2.3.1
Send2Trash                    1.8.0
setproctitle                  1.2.2
setuptools                    57.4.0
shellingham                   1.4.0
shiboken2                     5.15.2
simplejson                    3.17.5
six                           1.11.0
snowballstemmer               2.1.0
soupsieve                     2.2.1
speaklater                    1.3
Sphinx                        3.4.2
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-httpdomain      1.7.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
SQLAlchemy                    1.3.11
sqlparse                      0.3.1
tabulate                      0.8.9
team                          1.0
tenacity                      8.0.1
termcolor                     1.1.0
terminado                     0.11.1
terminaltables                3.1.0
testpath                      0.4.4
texttable                     1.6.4
tldr                          2.0.0
toml                          0.10.2
tomli                         1.2.1
tomlkit                       0.7.2
tornado                       6.1
traitlets                     5.0.5
trash-cli                     0.21.6.30
typed-ast                     1.4.2
typing-extensions             3.10.0.0
ueberzug                      18.1.9
ujson                         4.0.2
uritemplate                   3.0.1
urllib3                       1.26.6
urwid                         2.1.2
validate                      5.1.0.dev0
vine                          1.3.0
virtualenv                    20.7.2
virtualenv-clone              0.5.6
wcmatch                       8.2
wcwidth                       0.2.5
webencodings                  0.5.1
websocket-client              0.59.0
Werkzeug                      0.16.0
widgetsnbextension            3.5.1
wrapt                         1.12.1
yapf                          0.30.0
zipp                          0.6.0

Thanks Bernát!

gaborbernat commented 3 years ago

Seems either the OS or some of those installs messed up your installation because this requirement is not satisfied:

https://github.com/pypa/virtualenv/blob/main/setup.cfg#L43

This is why I always recommend you use https://pypa.github.io/pipx/installation/ via https://pypi.org/project/pipx-in-pipx/

Eothred commented 3 years ago

I can just mention that I ran across a similar issue on Manjaro now, after trying to get the backports package installed I finally succeeded by the more brutal deletion of ~/.local/lib/python3.9/, which I suppose also means I will never learn if I had precisely the same issue as OC or something vaguely relevant.

I guess my comment just states that it seems we manage to run into this issue at times on Arch based distros.