-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
ModuleNotFoundError: No module named 'django_project' when I used coverage run manage.py test #862
Comments
Hmm, this sounds concerning. Can you give me a way to reproduce the problem? |
I started off by creating a virtual environment in my project directory and activating the virtual environment. Within the activated environment I installed django and coverage ( didn't explicitly specify any version number, so the latest versions was installed -- django v3.0b and coverage v5.0a7), I then created a simple django model for an app and Test Cases for the model... With the TestCases created, I tried running coverage on my codebase and I get the above error. The error only occur when I run coverage run manage.py test but other coverage commands worked without any errors... Don't mind my response if it doesn't meet with what you expected, this is my very first bug report ( with a response ), I'm glad and willing to push the conversation further if need be |
@spaceofmiah I'm looking for very specific instructions. Exactly what code did you run? Do you have a GitHub repo I can use? Exactly what commands did you run? Ideally you would literally include "git clone ...." commands and so on. |
You can use this github repo https://github.com/spaceofmiah/coverage_report The instructions/commands to be used are highlighted on the README |
Thanks for the instructions, but I'm not seeing the error you are. I had to skip the "pipenv shell" step, because it threw an error, perhaps due to my zsh setup? Here's what I saw:
|
This is my workflow and the error log
|
This is another terminal log for the same project config, source code and everything but with coverage version 4.5 and the test runs perfectly fine
|
I fixed my issue with "pipenv shell" (a bad installation of Jython...), and I still don't see the error. I don't know what could be different between our environments. Can you add this to the top of manage.py:main():
and see what the difference is between the two versions of coverage.py? |
reinstalled coverage 5.0a7 after including to the main method of manage.py file the below scripts import pprint
pprint.pprint(sys.path) response from log
|
log response for coverage version 4.5
|
What version of Python exactly are you using? What do you see when you type just "python"? |
I'm using python 3.6.2
|
@spaceofmiah did you find a fix for this? I'm also running into a similar issue. Interestingly, the command |
@mpbrown Can you give me instructions for reproducing it? |
@mpbrown Thanks, but it's not failing for me. Something fundamental is different on my machine than the other people who can reproduce this. This is what I am seeing: git log -1
mktmpenv -p python3.6 -n
npm run setup
npm run assets
npm test
|
Same problem here. |
Same thing as above but with Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32 Seems to be windows issue since I don't get the ModuleNotFoundError with linux vagrant box. Coverage 4.5.4 is fine though. |
Same, using
Whereas the other reports seem to be WIndows, I'm on macOS Catalina.
To reproduce in my environment:
Outputs:
|
|
@jpmckinney Thanks, I was finally able to reproduce it myself. Ironically, this turned out to be the important bit:
It wasn't until I used pyenv and pyenv-virtualenv that the problem appeared for me. Now to work on a fix.... |
For those facing this problem: a work-around seems to be to use "python -m coverage run (etc)" instead of "coverage run (etc)". |
Not sure if this is the same problem: psf/black#1227. Black runs For some reason, the new Coverage.py version 5 is failing on Windows for Python 3.6 and 3.7.
It's passing on Windows for 3.8, and all Python versions on Ubuntu and macOS. Here's an older build that passed for everything, before Coverage.py 5 came out: Pinning to |
I have what I think is a fix for this problem. If people could try it and let me know, that would be a huge help:
/cc @hugovk @tritium21 @rly @jpmckinney @spaceofmiah @Temeez @mpbrown @obi-jerome |
Success! Thank you! |
@hugovk Thanks! Any other people with data points? |
@nedbat That fixed it! Thanks!! |
This is now available in 5.0.3: https://pypi.org/project/coverage/5.0.3/ |
Thank you! Confirmed fixed with 5.0.3. |
Watching for file changes with StatReloader Traceback (most recent call last): I am getting below error. Please help me in this regard. I am using python 3.7. Django 3.0.4. Please do let me know if you need more details |
Hey @Ravi9562 we have same problem, please tell me if u have done with this problem. i really" help |
@Ravi9562 @jericore it sounds like you are having an issue with Django. This page is for issues with a different package, coveragepy, not Django. For help with Django, please consult the official Django help page or post your question on StackOverflow. Good luck! |
I was into same error for me it was just because of running in a lot of errors i just unintentionally did some typo or changed the app name in Procfile and now it works fine. |
A great solution for running coverage on Local. |
Hello. |
I have managed to solve my issue above. Turns out when Pip/setuptools generate the .exe, they do hard-code a python executable in a shebang somewhere there. Luckily that part is visible with a plain text editor when opening the .exe and can be edited. |
I wanted to leave this here to hopefully help others coming across this issue in Django. Tried pretty much everything I could think of including the suggestions in this issue tracker with no luck. What fixed it for me was moving the coverage config out of |
The below issue is with Coverage version 5.0a7
When trying to run test for my django project using coverage run manage.py test i get
ModuleNotFoundError. This issue kept coming and i thought it was as a result of what was addressed here --> https://stackoverflow.com/questions/50378166/django-coverage-modulenotfounderror-no-module-named-django-extensions
None of the recommendations worked, i downgraded my django version from 3.0 to 2.2 and the problem persisted. This issue was rectified by downgrading to coverage version 4.5
Like i said, i only encountered this issue with coverage version 5.0a7
With the below dependencies, coverage is working as expected
complete error log
The text was updated successfully, but these errors were encountered: