question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pytest fails to load pooch in developer setup

See original GitHub issue

Describe the bug

The following Traceback is obtained when attempting to run any form of pytest, such as pytest mne/tests from the project root directory, when the current main is cloned on my system with the recommended YML-based environment creation and an editable pip install, with all requirements satisfied.

ImportError while loading conftest '/Users/tevesjb/repositories/mne-python/mne/conftest.py'.
mne/conftest.py:31: in <module>
    test_path = testing.data_path(download=False)
mne/datasets/testing/_testing.py:22: in data_path
    return _data_path(path=path, force_update=force_update,
mne/datasets/utils.py:213: in _data_path
    pooch = _soft_import('pooch', 'dataset downloading', strict=True)
mne/utils/check.py:273: in _soft_import
    raise RuntimeError(f'For {purpose} to work, the {name} module is '
E   RuntimeError: For dataset downloading to work, the pooch module is needed, but it could not be imported.

Steps to reproduce

pooch is available in the environment that the test is being run from:

>>> import pooch
>>> pooch.__version__
'v1.5.1'

Just as bizarrely, if I use the same facility as check.py, the load is successful:

>>> import mne
>>> from mne.utils.check import _soft_import
>>> p = _soft_import('pooch', 'dataset downloading', strict=True)
>>> print(p)
<module 'pooch' from '/Users/tevesjb/miniconda3/envs/mne-dev/lib/python3.9/site-packages/pooch/__init__.py'>

However, running pytest triggers the above RuntimeError and traceback, regardless of which test (presumably because the error occurs in test configuration).

Expected results

The tests at least run, even if they fail.

Actual results

The test configuration fails, so I can’t even use the debugger via pytest --trace.

Additional information

Platform:      macOS-10.15.7-x86_64-i386-64bit
Python:        3.9.7 | packaged by conda-forge | (default, Sep 23 2021, 07:31:23)  [Clang 11.1.0 ]
Executable:    /Users/tevesjb/miniconda3/envs/mne-dev/bin/python
CPU:           i386: 8 cores
Memory:        16.0 GB

mne:           0.24.dev0
numpy:         1.21.2 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:         1.7.0
matplotlib:    3.4.2 {backend=MacOSX}

sklearn:       0.24.2
numba:         0.53.1
nibabel:       3.2.1
nilearn:       0.8.0
dipy:          1.4.1
cupy:          Not found
pandas:        1.3.0
mayavi:        4.7.2
pyvista:       0.32.1 {pyvistaqt=0.5.0, OpenGL 4.1 INTEL-14.7.18 via Intel(R) Iris(TM) Plus Graphics OpenGL Engine}
vtk:           9.0.1
PyQt5:         5.12.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
drammockcommented, Oct 12, 2021

apparently I was a few days behind and missed that; with the actually up-to-date main this bug does not exist

closing because already fixed

0reactions
larsonercommented, Oct 1, 2021

I’m up for making a short PR; is there a relevant issue or should I just add it to the referenced tuple?

You can just add it to the tuple I think, and update toward the top of the Enhancements section of doc/changes/latest.inc (with the special “new contributor” substitution + bolding), and also doc/changes/names.inc to add your name!

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytest cannot import module while python can - Stack Overflow
The solution was to install pytest in the virtual environment. (In case your shell hashes executables, as Bash does, use hash -r ,...
Read more >
Cannot install for development - dependencies ... - GitHub
I'm trying to install for development as described here https://hvplot.holoviz.org/developer_guide/index.html#conda-environments.
Read more >
Installing — Pooch v0.5.2 - Fatiando a Terra
We recommend using the Anaconda Python distribution to ensure you have all dependencies installed and the conda package manager available.
Read more >
Getting Started Unit Testing with Pytest - Towards Data Science
pip install pytest ... import project # test basic functionality ... Not only does pytest make it clear that our test failed, ...
Read more >
Pytest Unit Testing Tutorial • How to test your Python code
Chapters 00:00 Introduction 02:45 Install Pytest and setup the ... "assert") 11:24 How to test that an Error is raised 18:30 How to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found