ModuleNotFoundError: Command `doctest` not found by nbqa
See original GitHub issueHow do I use nbqa
with doctest
? I tried nbqa doctest mynb.ipynb
and got an error ModuleNotFoundError: Command
doctest not found by nbqa
I can run doctest if I do nbconvert
then python -m doctest mynb.ipynb
% nbqa --version
nbqa 0.3.3
% nbqa doctest mynb.ipynb
Traceback (most recent call last):
File "/Users/ntaylor/src/nanml-notebook/docs/venv/bin/nbqa", line 8, in <module>
sys.exit(main())
File "/Users/ntaylor/src/nanml-notebook/docs/venv/lib/python3.8/site-packages/nbqa/__main__.py", line 531, in main
output_codes = [
File "/Users/ntaylor/src/nanml-notebook/docs/venv/lib/python3.8/site-packages/nbqa/__main__.py", line 532, in <listcomp>
_run_on_one_root_dir(i, cli_args, configs, project_root)
File "/Users/ntaylor/src/nanml-notebook/docs/venv/lib/python3.8/site-packages/nbqa/__main__.py", line 474, in _run_on_one_root_dir
out, err, output_code, mutated = _run_command(
File "/Users/ntaylor/src/nanml-notebook/docs/venv/lib/python3.8/site-packages/nbqa/__main__.py", line 355, in _run_command
raise ModuleNotFoundError(_get_command_not_found_msg(command))
ModuleNotFoundError: Command `doctest` not found by nbqa.
Please make sure you have it installed in the same Python environment as nbqa. See
e.g. https://realpython.com/python-virtual-environments-a-primer/ for how to set up
a virtual environment in Python.
Since nbqa is installed at /Users/ntaylor/src/nanml-notebook/docs/venv/lib/python3.8/site-packages/nbqa and uses the Python executable found at
/Users/ntaylor/src/nanml-notebook/docs/venv/bin/python, you could fix this issue by running `/Users/ntaylor/src/nanml-notebook/docs/venv/bin/python -m pip install doctest`.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
nbQA Documentation
nbqa mypy my_notebook.ipynb --ignore-missing-imports my_notebook.ipynb:cell_10:5: error: Argument "num1" to "add" has incompatible type ...
Read more >Doctests fail on Python 3 · Issue #447 · asdf-format/asdf - GitHub
It seems that the 1.3.2 release was not done at the master branch: This is asdf/util.py in 1.3.2; still containing the lines from...
Read more >python doctest is not running test when I'm running command ...
When I'm running below command from cmdline. python3.7 -m doctest -v src/helpers/string.py. This doesn't run any test.
Read more >nbqa Changelog - PyUp.io
Fixed bug whereby local scripts / modules could not be run by ``nbQA`` due to incorrect ``ModuleNotFoundError``. 0.13.0. ~~~~~ ...
Read more >doctest — Test interactive Python examples — Python 3.11.1 ...
The framework author typically wants to control doctest reporting options (perhaps, e.g., specified by command line options), but there's no way to pass...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I have an idea, actually - does your doctest import something it’s not able to find?
The problem is that to detect whether you have the code quality tool you’re running installed or not, we do
However, this is buggy, because
No module named
might be returned by the code quality tool itself! So, we have a bug.In the short-run, I’d recommend fixing your docstring so that everything you use in it was imported correctly. We’ll make a patch release for this at the weekend - @s-weigand had suggested a better way of checking if packages are installed, and I wish I’d followed his advice immediately now 😳
@all-contributors please add @ntaylor-nanigans for bug
closed in #365
@ntaylor-nanigans please try upgrading to version 0.3.4, I’d like to think this is fixed - if there are issues, please do let us know!