pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
12.17k stars 2.7k forks source link

After latest release (3.3.0) I'm getting `ImportError: No module named _pluggy` #2960

Closed david-caro closed 7 years ago

david-caro commented 7 years ago

With the latest pytest release (3.3.0) when trying to run the tests I get the error:

Traceback (most recent call last):
  File "/virtualenv/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/virtualenv/lib/python2.7/site-packages/_pytest/config.py", line 50, in main
    config = _prepareconfig(args, plugins)
  File "/virtualenv/lib/python2.7/site-packages/_pytest/config.py", line 160, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "/virtualenv/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/virtualenv/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/virtualenv/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/virtualenv/lib/python2.7/site-packages/pluggy/callers.py", line 196, in _multicall
    gen.send(outcome)
  File "/virtualenv/lib/python2.7/site-packages/_pytest/helpconfig.py", line 68, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/virtualenv/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
    _reraise(*ex)  # noqa
  File "/virtualenv/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/virtualenv/lib/python2.7/site-packages/_pytest/config.py", line 942, in pytest_cmdline_parse
    self.parse(args)
  File "/virtualenv/lib/python2.7/site-packages/_pytest/config.py", line 1107, in parse
    self._preparse(args, addopts=addopts)
  File "/virtualenv/lib/python2.7/site-packages/_pytest/config.py", line 1070, in _preparse
    self.pluginmanager.load_setuptools_entrypoints('pytest11')
  File "/virtualenv/lib/python2.7/site-packages/pluggy/__init__.py", line 397, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2405, in load
    return self.resolve()
  File "/virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2411, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/virtualenv/lib/python2.7/site-packages/_pytest/assertion/rewrite.py", line 212, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/virtualenv/lib/python2.7/site-packages/py/_builtin.py", line 221, in exec_
    exec2(obj, globals, locals)
  File "<string>", line 7, in exec2
  File "/virtualenv/lib/python2.7/site-packages/pytest_metadata/plugin.py", line 8, in <module>
    import _pytest._pluggy as pluggy
ImportError: No module named _pluggy

If I just downgrade to 3.2.5 everything works:

======================================================== test session starts =========================================================
platform linux2 -- Python 2.7.5, pytest-3.2.5, py-1.5.2, pluggy-0.4.0
sensitiveurl: .*
metadata: {'Python': '2.7.5', 'Driver': None, 'Capabilities': {}, 'Base URL': '', 'Platform': 'Linux-4.13.13-300.fc27.x86_64-x86_64-with-centos-7.4.1708-Core', 'Plugins': {'base-url': '1.4.1', 'cov': '2.5.1', 'variables': '1.7.0', 'selenium': '1.11.2', 'html': '1.16.0', 'metadata': '1.5.0', 'flake8': '0.9.1'}, 'Packages': {'py': '1.5.2', 'pytest': '3.2.5', 'pluggy': '0.4.0'}}
rootdir: /code, inifile: setup.cfg
plugins: variables-1.7.0, selenium-1.11.2, metadata-1.5.0, html-1.16.0, flake8-0.9.1, cov-2.5.1, base-url-1.4.1
collected 16 items  
...

The pip list:

alabaster (0.7.10)
alembic (0.9.6)
amqp (1.4.9)
anyjson (0.3.3)
argcomplete (1.9.3)
arrow (0.12.0)
asciitree (0.3.3)
asn1crypto (0.23.0)
attrs (17.3.0)
Automat (0.6.0)
autosemver (0.5.3)
Babel (2.5.1)
backoff (1.4.3)
backports-abc (0.5)
backports.functools-lru-cache (1.2.1)
backports.shutil-get-terminal-size (1.0.0)
backports.ssl-match-hostname (3.5.0.1)
backports.tempfile (1.0)
backports.weakref (1.0.post1)
beard (0.2)
beautifulsoup4 (4.6.0)
billiard (3.3.0.23)
binaryornot (0.4.4)
blinker (1.4)
celery (3.1.25)
certifi (2017.11.5)
cffi (1.11.2)
chardet (3.0.4)
click (6.7)
configobj (5.0.6)
configparser (3.5.0)
constantly (15.1.0)
contextlib2 (0.5.5)
cookiecutter (1.6.0)
coverage (4.4.2)
cryptography (2.1.3)
cssselect (1.0.1)
decorator (4.1.2)
dictdiffer (0.7.0)
docutils (0.14)
dojson (1.3.2)
dulwich (0.18.6)
editdistance (0.4)
elasticsearch (2.4.1)
elasticsearch-dsl (2.2.0)
enum34 (1.1.6)
fancycompleter (0.8)
flake8 (3.5.0)
flake8-future-import (0.4.3)
Flask (0.12.2)
Flask-Admin (1.5.0)
Flask-Alembic (2.0.1)
Flask-Assets (0.12)
Flask-BabelEx (0.9.3)
Flask-Breadcrumbs (0.4.0)
Flask-Caching (1.3.3)
Flask-CeleryExt (0.3.0)
Flask-CLI (0.4.0)
Flask-Collect (1.2.2)
Flask-Cors (3.0.3)
Flask-Gravatar (0.4.2)
Flask-KVSession (0.6.2)
Flask-Login (0.4.0)
Flask-Mail (0.9.1)
Flask-Menu (0.6.0)
Flask-OAuthlib (0.9.4)
Flask-Principal (0.4.0)
Flask-Security (3.0.0)
flask-shell-ipython (0.3.0)
Flask-SQLAlchemy (2.3.2)
Flask-WTF (0.14.2)
flower (0.9.2)
fs (0.5.5a1)
ftputil (3.4)
funcsigs (1.0.2)
functools32 (3.2.3.post2)
furl (1.0.1)
future (0.16.0)
futures (3.1.1)
Fuzzy (1.2.2)
gunicorn (19.7.1)
HarvestingKit (0.6.13)
hepcrawl (4.0.3)
HTMLParser (0.0.2)
httplib2 (0.10.3)
httpretty (0.8.14)
hyperlink (17.3.1)
idna (2.6)
IDUtils (0.2.4)
imagesize (0.7.1)
incremental (17.5.0)
inspire-crawler (1.0.0)
inspire-dojson (55.0.2)
inspire-json-merger (5.0.1)
inspire-matcher (2.0.1)
inspire-query-parser (2.0.0)
inspire-schemas (55.0.4)
inspire-utils (1.0.1)
Inspirehep (0.1.0, /code)
invenio-access (1.0.0b1)
invenio-accounts (1.0.0b10)
invenio-admin (1.0.0b4)
invenio-assets (1.0.0b7)
invenio-base (1.0.0a16)
invenio-cache (1.0.0b1)
invenio-celery (1.0.0b3)
invenio-classifier (1.3.1)
invenio-collections (1.0.0a4)
invenio-config (1.0.0b3)
invenio-db (1.0.0b9)
invenio-files-rest (1.0.0a21)
invenio-i18n (1.0.0b4)
invenio-indexer (1.0.0a10)
invenio-jsonschemas (1.0.0a7)
invenio-logging (1.0.0b3)
invenio-mail (1.0.0b1)
invenio-oaiharvester (1.0.0a3)
invenio-oauthclient (1.0.0b3)
invenio-pidstore (1.0.0b2)
invenio-query-parser (0.6.0)
invenio-record-editor (0.1.0.dev20160000, /virtualenv/src/invenio-record-editor)
invenio-records (1.0.0b4)
invenio-records-files (1.0.0a9)
invenio-records-rest (1.0.0b3)
invenio-records-ui (1.0.0b1)
invenio-rest (1.0.0b2)
invenio-search (1.0.0b1)
invenio-userprofiles (1.0.0b2)
invenio-workflows (7.0.0)
invenio-workflows-files (1.0.0)
invenio-workflows-ui (2.0.0)
ipaddr (2.2.0)
ipaddress (1.0.18)
ipdb (0.10.3)
ipython (5.5.0)
ipython-genutils (0.2.0)
isbnid-fork (0.5.2)
isodate (0.6.0)
itsdangerous (0.24)
jellyfish (0.5.6)
Jinja2 (2.10)
jinja2-time (0.2.0)
json-merger (0.4.0)
jsonpatch (1.20)
jsonpointer (1.14)
jsonref (0.1)
jsonresolver (0.2.1)
jsonschema (2.6.0)
kombu (3.0.37)
langdetect (1.0.7)
librabbitmq (1.6.1)
LinkHeader (0.4.3)
lxml (4.1.1)
Mako (1.0.7)
MarkupSafe (1.0)
marshmallow (3.0.0b4)
maxminddb (1.3.0)
maxminddb-geolite2 (2017.803)
mccabe (0.6.1)
meld3 (1.0.2)
mock (2.0.0)
msgpack-python (0.4.8)
munkres (1.0.12)
nameparser (0.5.3)
node-semver (0.1.1)
numpy (1.13.3)
oauthlib (2.0.6)
orcid (0.7.0)
ordereddict (1.1)
orderedmultidict (0.7.11)
parsel (1.2.0)
passlib (1.7.1)
pathlib2 (2.3.0)
pbr (3.1.1)
pdbpp (0.9.2)
pexpect (4.3.0)
pickleshare (0.7.4)
pip (9.0.1)
plotextractor (0.1.6)
pluggy (0.6.0)
poyo (0.4.1)
prompt-toolkit (1.0.15)
psycopg2 (2.7.3.2)
ptyprocess (0.5.2)
py (1.5.2)
pyasn1 (0.4.2)
pyasn1-modules (0.2.1)
pycodestyle (2.3.1)
pycountry (17.9.23)
pycparser (2.18)
PyDispatcher (2.0.5)
pyflakes (1.6.0)
Pygments (2.2.0)
PyJWT (1.5.3)
pyOpenSSL (17.4.0)
pyparsing (2.2.0)
PyPDF2 (1.26.0)
pyPEG2 (2.15.2)
pyrepl (0.8.4)
pyrsistent (0.14.1)
pytest (3.3.0)
pytest-base-url (1.4.1)
pytest-cov (2.5.1)
pytest-flake8 (0.9.1)
pytest-html (1.16.0)
pytest-metadata (1.5.0)
pytest-runner (3.0)
pytest-selenium (1.11.2)
pytest-variables (1.7.0)
python-dateutil (2.6.1)
python-editor (1.0.3)
python-magic (0.4.13)
python-redis-lock (3.2.0)
python-scrapyd-api (2.0.1)
pytz (2017.3)
PyYAML (3.12)
queuelib (1.4.2)
raven (6.3.0)
rdflib (4.2.2)
redis (2.10.6)
refextract (0.2.2)
requests (2.18.4)
requests-mock (1.3.0)
requests-oauthlib (0.8.0)
rfc3987 (1.3.7)
rt (1.0.10, /virtualenv/src/rt)
scandir (1.6)
scikit-learn (0.19.1)
scipy (1.0.0)
Scrapy (1.4.0)
scrapy-crawl-once (0.1.1)
scrapyd (1.1.0)
scrapyd-client (1.2.0a1)
selenium (3.7.0)
service-identity (17.0.0)
setproctitle (1.1.10)
setuptools (38.2.3)
Sickle (0.6.2)
simplegeneric (0.8.1)
simplejson (3.13.2)
simplekv (0.10.0)
singledispatch (3.4.0.3)
six (1.11.0)
snowballstemmer (1.2.1)
speaklater (1.3)
Sphinx (1.5.6)
SQLAlchemy (1.1.15)
SQLAlchemy-Continuum (1.3.3)
sqlalchemy-mptt (0.2.2)
SQLAlchemy-Utils (0.32.21)
sqlitedict (1.5.0)
subprocess32 (3.5.0rc1)
superlance (1.0.0)
supervisor (3.3.3)
sword2 (0.1, /virtualenv/src/sword2)
timeout-decorator (0.4.0)
tornado (4.5.2)
traitlets (4.3.2)
Twisted (17.9.0)
ua-parser (0.7.3)
Unidecode (0.4.21)
uritools (2.1.0)
urllib3 (1.22)
w3lib (1.18.0)
Wand (0.4.4)
wcwidth (0.1.7)
webargs (1.8.1)
webassets (0.12.1)
Werkzeug (0.12.2)
wheel (0.30.0)
whichcraft (0.4.1)
wmctrl (0.3)
workflow (2.1.3)
WTForms (2.1)
zope.interface (4.4.3)

Looking how to get a minimal example.

blueyed commented 7 years ago

Caused by pytest-metadata apparently.

The-Compiler commented 7 years ago

Yup - see https://github.com/davehunt/pytest-metadata/issues/5

laurianops commented 3 years ago

I have a similar error

(venv) lauriano@lauriano:~/lauria-no/adriano$ docker-compose exec web pytest -pdb Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 703, in import_plugin import(importspec) ModuleNotFoundError: No module named 'db'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/bin/pytest", line 8, in sys.exit(console_main()) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 185, in console_main code = main() File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 143, in main config = _prepareconfig(args, plugins) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 318, in _prepareconfig config = pluginmanager.hook.pytest_cmdline_parse( File "/usr/local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall gen.send(outcome) File "/usr/local/lib/python3.8/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse config: Config = outcome.get_result() File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall res = hook_impl.function(*args) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 1003, in pytest_cmdline_parse self.parse(args) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 1283, in parse self._preparse(args, addopts=addopts) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 1168, in _preparse self.pluginmanager.consider_preparse(args, exclude_only=False) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 635, in consider_preparse self.consider_pluginarg(parg) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 660, in consider_pluginarg self.import_plugin(arg, consider_entry_points=True) File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 705, in import_plugin raise ImportError( File "/usr/local/lib/python3.8/site-packages/_pytest/config/init.py", line 703, in import_plugin import(importspec) ImportError: Error importing plugin "db": No module named 'db' ERROR: 1

RonnyPfannschmidt commented 3 years ago

@LaurianoElmiroDuarte wrong issue, you forgot a - before --pdb making it it the ``` -p db