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

run -m cannot find module (or package) in current directory #207

Closed
nedbat opened this issue Oct 25, 2012 · 5 comments
Closed

run -m cannot find module (or package) in current directory #207

nedbat opened this issue Oct 25, 2012 · 5 comments
Labels
bug Something isn't working run

Comments

@nedbat
Copy link
Owner

nedbat commented Oct 25, 2012

Originally reported by Antony Lee (Bitbucket: anntzer, GitHub: anntzer)


The directory from which coverage was started should be added at the beginning of sys.path (or perhaps even replace the first entry of sys.path, which is the directory where coverage is installed), so that coverage run -m foo can find foo in that directory (just as python -m foo can find foo in that directory).

Perhaps this modification should be made temporary though (e.g. by fooling around in execfile.py).


@nedbat
Copy link
Owner Author

nedbat commented Nov 6, 2012

Can you provide more details? I've tried but can't reproduce the problem you're reporting. Do you have a zipfile that demonstrates it? What OS and Python version are you using?

@nedbat
Copy link
Owner Author

nedbat commented Nov 6, 2012

Original comment by Antony Lee (Bitbucket: anntzer, GitHub: anntzer)


Create a folder package containing (empty) files __init__.py and __main__.py, and try coverage run -m package (from the folder containing package). I get the error message No module named 'package', sometimes with the extra error

"Exception AttributeError: "'NoneType' object has no attribute 'isabs'" in <function _remove at ...> ignored"

(this error may or may not appear in a seemingly random fashion). On the other hand python -m package works as expected.

This is on Arch Linux with Python 2.7.3 or 3.3.0, and coverage 3.5.2.

@nedbat
Copy link
Owner Author

nedbat commented Nov 7, 2012

Re-opening while we track this down.

@nedbat
Copy link
Owner Author

nedbat commented Nov 12, 2012

BTW: the attribute error is the subject of bug #153, which is now fixed.

@nedbat
Copy link
Owner Author

nedbat commented Apr 20, 2013

Fixed in changeset fb577266b491 (bb).

@nedbat nedbat closed this as completed Apr 20, 2013
@nedbat nedbat added major bug Something isn't working run labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working run
Projects
None yet
Development

No branches or pull requests

1 participant