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

On startup: AttributeError: 'str' object has no attribute 'pattern' #6472

Closed
rubik opened this issue Jan 16, 2020 · 6 comments
Closed

On startup: AttributeError: 'str' object has no attribute 'pattern' #6472

rubik opened this issue Jan 16, 2020 · 6 comments
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@rubik
Copy link

rubik commented Jan 16, 2020

Pytest fails on startup with the following traceback:

$ pytest
Traceback (most recent call last):
  File "/home/dev/.local/share/virtualenvs/backend/bin/pytest", line 5, in <module>
    from pytest import main
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/pytest.py", line 7, in <module>
    from _pytest.assertion import register_assert_rewrite
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/_pytest/assertion/__init__.py", line 12, in <module>
    from _pytest.assertion import rewrite
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 23, in <module>
    from _pytest.assertion import util
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/_pytest/assertion/util.py", line 10, in <module>
    import _pytest._code
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/_pytest/_code/__init__.py", line 6, in <module>
    from .code import Code  # noqa
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/_pytest/_code/code.py", line 14, in <module>
    import pluggy
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/pluggy/__init__.py", line 16, in <module>
    from .manager import PluginManager, PluginValidationError
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/pluggy/manager.py", line 6, in <module>
    import importlib_metadata
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 478, in <module>
    __version__ = version(__name__)
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 445, in version
    return distribution(package).version
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 418, in distribution
    return Distribution.from_name(package)
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 179, in from_name
    dists = resolver(name)
  File "<frozen importlib._bootstrap_external>", line 1382, in find_distributions
  File "/home/dev/.local/share/virtualenvs/backend/lib/python3.8/importlib/metadata.py", line 400, in find_distributions
    found = cls._search_paths(context.pattern, context.path)
AttributeError: 'str' object has no attribute 'pattern'

Python version: 3.8.1
Pytest version: 4.5.0
OS: Archlinux 5.4.3

Other packages:

atomicwrites==1.3.0
attrs==19.1.0
backports.functools-lru-cache==1.5
certifi==2019.6.16
chardet==3.0.4
contextlib2==0.5.5
coverage==4.5.4
docopt==0.6.2
future==0.17.1
idna==2.8
importlib-metadata==0.19
jmespath==0.9.4
more-itertools==7.2.0
paho-mqtt==1.3.1
pbr==5.4.2
pluggy==0.12.0
py==1.8.0
pyjwt==1.7.1
pykwalify==1.7.0
pytest-cov==2.7.1
pytest==4.5.0
python-box==3.4.2
python-dateutil==2.8.0
pyyaml==5.1.2
requests==2.22.0
six==1.12.0
stevedore==1.30.1
tavern==0.27.0
urllib3==1.25.3
wcwidth==0.1.7
zipp==0.5.2
@The-Compiler
Copy link
Member

The-Compiler commented Jan 16, 2020

If you run /home/dev/.local/share/virtualenvs/backend/bin/python -c 'import importlib_metadata', does the same happen as well?

@The-Compiler
Copy link
Member

Issues which look somewhat related:

So you might want to try upgrading your importlib-metadata and/or pluggy.

@nicoddemus nicoddemus added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Jan 16, 2020
@rubik
Copy link
Author

rubik commented Jan 16, 2020

@The-Compiler Thanks, that clarifies the issue. But then I think Pytest should also update its requirements. It should not depend on a broken package.

@asottile
Copy link
Member

@rubik it doesn't, in python3.8 we don't use importlib_metadata we use importlib.metadata

@asottile
Copy link
Member

you're on a very old version of pytest which is probably why it's being pulled in erroneously

@rubik
Copy link
Author

rubik commented Jan 16, 2020

@asottile My bad, you are right. There was another package pinning it down. Thanks, for the help.

@rubik rubik closed this as completed Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

4 participants