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.

Improve 'module not found' message

See original GitHub issue

In #1567 it was men, user has spent a long time trying to figure out why their namespace package was not being found, reason being that pytest does not support namespace packages via --pyargs (#478).

One easy suggestion is to improve the error message, from:

ERROR: module or package not found: module.misc (missing __init__.py?)

To something like this:

ERROR: pytest cannot import module or package 'module.misc'
Possible reasons:
- Missing an __init__.py file
- Namespace package (not supported)
- Not reachable via PYTHONPATH
See <link to docs> for more information.

Bonus points if we link to a documentation where we have an explanation for each bullet point above.

_Originally posted by @nicoddemus in https://github.com/pytest-dev/pytest/issues/1567#issuecomment-1342649479_

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dimpasecommented, Dec 8, 2022

Our (for SageMath) main use of pytest would be to run doctests (in Python and in Cython). This can be done on per-file basis, in parallel (otherwise it takes many hours of wallclock time). But pytest makes it unnecessary hard to do things like pytest foo/*/* – all these missing __init__.py errors. Currently we have a homemade tool which uses a bit of Python doctest module for this, but it’s old and tired, and we really want an off the shelf solution instead.

0reactions
RonnyPfannschmidtcommented, Dec 10, 2022

No promises

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve "Cannot find module" error · Issue #26588 - GitHub
While trying to debug an issue, I found the error message from node to be slightly misleading and/or not as useful as it...
Read more >
How do I resolve "Cannot find module" error using Node.js?
it seems like when i installed it globally the npm/node-modules folder was empty and i was trying to use ng new project-name it...
Read more >
How to Resolve MODULE NOT FOUND error in Python l Error ...
In this tutorial I will be showing you how to resolve the error message " Module Not Found ". This tutorial provides a...
Read more >
How to fix "The following module is missing from the file ...
Restore the module and actually disable and uninstall it (recommended if possible): First, restore the module to its original location in the file...
Read more >
ModuleNotFoundError: no module named Python Error [Fixed]
How to fix the ModuleNotFoundError in Python · 1. Make sure imported modules are installed · 2. Make sure modules are spelled correctly...
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