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

ModuleNotFoundError: No module named 'django_project' when I used coverage run manage.py test #862

Closed
spaceofmiah opened this issue Oct 24, 2019 · 40 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@spaceofmiah
Copy link

spaceofmiah commented Oct 24, 2019

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

λ pipenv run pip list
Package          Version
---------------- -------
asgiref              3.2.3
coverage          4.5
Django              2.2
Pillow               6.2.1
pip                   19.3.1
psycopg2         2.8.4
pytz                2019.3
setuptools       41.4.0
sqlparse         0.3.0
wheel            0.33.6

complete error log

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'newproject'
@spaceofmiah spaceofmiah added the bug Something isn't working label Oct 24, 2019
@nedbat
Copy link
Owner

nedbat commented Oct 24, 2019

Hmm, this sounds concerning. Can you give me a way to reproduce the problem?

@spaceofmiah
Copy link
Author

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

@nedbat
Copy link
Owner

nedbat commented Oct 25, 2019

@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.

@spaceofmiah
Copy link
Author

You can use this github repo https://github.com/spaceofmiah/coverage_report

The instructions/commands to be used are highlighted on the README

@nedbat
Copy link
Owner

nedbat commented Oct 25, 2019

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:

@/tmp/bug862 % git clone https://github.com/spaceofmiah/coverage_report.git
Cloning into 'coverage_report'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 63 (delta 24), reused 46 (delta 17), pack-reused 0
Unpacking objects: 100% (63/63), done.

@/tmp/bug862 % cd coverage_report

@/tmp/bug862/coverage_report master ± mktmpenv -p python3.6 -n
Running virtualenv with interpreter /usr/local/bin/python3.6
Using base prefix '/usr/local/pythonz/pythons/CPython-3.6.9'
New python executable in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/bin/python3.6
Also creating executable in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/bin/python
Installing setuptools, pip, wheel...done.
Requirement already up-to-date: pip in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (19.3.1)
Requirement already up-to-date: setuptools in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (41.4.0)
This is a temporary environment. It will be deleted when you run 'deactivate'.

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master ± pip install pipenv
Collecting pipenv
  Using cached https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl
Collecting virtualenv-clone>=0.2.5
  Using cached https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/c5/97/00dd42a0fc41e9016b23f07ec7f657f636cb672fad9cf72b80f8f65c6a46/virtualenv-16.7.7-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (from pipenv) (41.4.0)
Collecting certifi
  Using cached https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl
Requirement already satisfied: pip>=9.0.1 in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (from pipenv) (19.3.1)
Installing collected packages: virtualenv-clone, virtualenv, certifi, pipenv
Successfully installed certifi-2019.9.11 pipenv-2018.11.26 virtualenv-16.7.7 virtualenv-clone-0.5.3

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master ± pipenv install
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing dependencies from Pipfile.lock (b9e230)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:07

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master ± coverage run manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 test in 0.004s

OK
Destroying test database for alias 'default'...

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master(+0/-0) ± pipenv run pip list
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Package          Version
---------------- ----------
asgiref          3.2.3
certifi          2019.9.11
coverage         5.0a7
Django           3.0b1
pip              19.3.1
pipenv           2018.11.26
pytz             2019.3
setuptools       41.4.0
sqlparse         0.3.0
virtualenv       16.7.7
virtualenv-clone 0.5.3
wheel            0.33.6

@spaceofmiah
Copy link
Author

This is my workflow and the error log

C:\Users\spaceofmiah\dev\Python\django
λ cd coverage_report\

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ pipenv shell
Launching subshell in virtual environment…

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   5.0a7
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ coverage run manage.py test
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coverage_report'

@spaceofmiah
Copy link
Author

spaceofmiah commented Oct 26, 2019

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

  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coverage_report'

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ pipenv install coverage
Installing coverage…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Installing dependencies from Pipfile.lock (b9e230)…
  ================================ 5/5 - 00:00:05

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   5.0a7
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ pipenv install coverage==4.5
Installing coverage==4.5…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (d8e430) out of date, updating to (b9e230)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (d8e430)!
Installing dependencies from Pipfile.lock (d8e430)…
  ================================ 5/5 - 00:00:04

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   4.5
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ coverage run manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
Destroying test database for alias 'default'...

@nedbat
Copy link
Owner

nedbat commented Oct 28, 2019

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():

import pprint
pprint.pprint(sys.path)

and see what the difference is between the two versions of coverage.py?

@spaceofmiah
Copy link
Author

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

pipenv install --pre coverage==5.0a7
Installing coverage==5.0a7…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (b9e230) out of date, updating to (d8e430)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (b9e230)!
Installing dependencies from Pipfile.lock (b9e230)…
  ================================ 5/5 - 00:00:04



λ pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   5.0a7
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6



C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ coverage run manage.py test
['C:\\Users\\spaceofmiah\\.virtualenvs\\coverage_report-kFgWHH1O\\Scripts\\coverage.exe',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts\\python36.zip',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\Lib',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib\\site-packages']
Traceback (most recent call last):
  File "manage.py", line 23, in <module>
    main()
  File "manage.py", line 19, in main
    execute_from_command_line(sys.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coverage_report'

@spaceofmiah
Copy link
Author

log response for coverage version 4.5

λ pipenv install coverage==4.5
Installing coverage==4.5…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (d8e430) out of date, updating to (b9e230)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (d8e430)!
Installing dependencies from Pipfile.lock (d8e430)…
  ================================ 5/5 - 00:00:05

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
λ coverage run manage.py test
['C:\\Users\\spaceofmiah\\dev\\Python\\django\\coverage_report',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts\\python36.zip',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\Lib',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib\\site-packages']
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
Destroying test database for alias 'default'...

@nedbat
Copy link
Owner

nedbat commented Oct 30, 2019

What version of Python exactly are you using? What do you see when you type just "python"?

@spaceofmiah
Copy link
Author

I'm using python 3.6.2
when i type just "python", python interpreter is opened

C:\Users\spaceofmiah\dev\Python\django\jst\coverage_report (master -> origin)
λ python --version
Python 3.6.2

C:\Users\spaceofmiah\dev\Python\django\jst\coverage_report (master -> origin)
λ python
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

@mpbrown
Copy link

mpbrown commented Dec 27, 2019

@spaceofmiah did you find a fix for this? I'm also running into a similar issue. Interestingly, the command coverage run manage.py test is successful on Travis CI, but doesn't work locally. Running python manage.py test is successful locally. Repo

@nedbat
Copy link
Owner

nedbat commented Dec 27, 2019

@mpbrown Can you give me instructions for reproducing it?

@nedbat nedbat added this to the 5.0.2 milestone Jan 2, 2020
@mpbrown
Copy link

mpbrown commented Jan 2, 2020

@nedbat After cloning the repo, first run npm run setup and npm run assets to set up the environment using npm scripts. Then npm test to reproduce the ModuleNotFoundError.

Also I should note that the coverage command was previously working correctly even in November.

@nedbat
Copy link
Owner

nedbat commented Jan 3, 2020

@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
 commit 872a43d298f4f59865aebda310f78f4ea787b986 (HEAD -> master, origin/master, origin/HEAD)
 Author: Mike Brown <mpbrown@buffalo.edu>
 Date:   Fri Jan 3 10:34:34 2020 -0500

     Add test for ReviewEligibilityView
mktmpenv -p python3.6 -n
Running virtualenv with interpreter /usr/local/bin/python3.6
Using base prefix '/usr/local/pythonz/pythons/CPython-3.6.9'
New python executable in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/bin/python3.6
Also creating executable in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/bin/python
Installing setuptools, pip, wheel...done.
Requirement already up-to-date: pip in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (19.3.1)
Requirement already up-to-date: setuptools in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (44.0.0)
This is a temporary environment. It will be deleted when you run 'deactivate'.
(tmp-d01cca5ee5cb7c10)
npm run setup
> getbuffalowater@1.0.0 setup /src/foo/bug862/affordable_water
> npm run python-setup && npm install


> getbuffalowater@1.0.0 python-setup /src/foo/bug862/affordable_water
> pip install pipenv && pipenv sync

Collecting pipenv
  Using cached https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl
Collecting certifi
  Using cached https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl
Collecting virtualenv-clone>=0.2.5
  Using cached https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (from pipenv) (44.0.0)
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/05/f1/2e07e8ca50e047b9cc9ad56cf4291f4e041fa73207d000a095fe478abf84/virtualenv-16.7.9-py2.py3-none-any.whl
Requirement already satisfied: pip>=9.0.1 in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (from pipenv) (19.3.1)
Installing collected packages: certifi, virtualenv-clone, virtualenv, pipenv
Successfully installed certifi-2019.11.28 pipenv-2018.11.26 virtualenv-16.7.9 virtualenv-clone-0.5.3
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing dependencies from Pipfile.lock (9e2090)…
Ignoring atomicwrites: markers 'sys_platform == "win32"' don't match your environment
Ignoring colorama: markers 'sys_platform == "win32"' don't match your environment
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 40/40 — 00:02:42
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
npm WARN The package gulp is included as both a dev and production dependency.

audited 8256 packages in 2.833s
found 0 vulnerabilities
npm run assets
> getbuffalowater@1.0.0 assets /src/foo/bug862/affordable_water
> npm run gulp && npm run collectstatic && npm run compress


> getbuffalowater@1.0.0 gulp /src/foo/bug862/affordable_water
> pipenv run gulp

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
[11:14:14] Using gulpfile /src/foo/bug862/affordable_water/gulpfile.js
[11:14:14] Starting 'default'...
[11:14:14] Starting 'bourbon'...
[11:14:14] Finished 'bourbon' after 129 ms
[11:14:14] Starting 'normalize'...
[11:14:15] Finished 'normalize' after 21 ms
[11:14:15] Starting 'neat'...
[11:14:15] Finished 'neat' after 84 ms
[11:14:15] Finished 'default' after 238 ms

> getbuffalowater@1.0.0 collectstatic /src/foo/bug862/affordable_water
> pipenv run python manage.py collectstatic --noinput

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.

119 static files copied to '/src/foo/bug862/affordable_water/staticfiles', 264 unmodified, 564 post-processed.

> getbuffalowater@1.0.0 compress /src/foo/bug862/affordable_water
> pipenv run python manage.py compress

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Compressing... done
Compressed 1 block(s) from 34 template(s) for 0 context(s).
npm test
> getbuffalowater@1.0.0 test /src/foo/bug862/affordable_water
> pipenv run python manage.py test

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.................................................................................
----------------------------------------------------------------------
Ran 81 tests in 8.491s

OK
Destroying test database for alias 'default'...

@nedbat nedbat modified the milestones: 5.0.2, 5.0.3 Jan 6, 2020
@obi-081
Copy link

obi-081 commented Jan 6, 2020

Same problem here.
Python 3.6.8 [MSC v.1916 64 bit (AMD64)] on win32
No Problem with coverage==4.5.4
Fail with coverage==5.0.2
When I look at this thread, I see that @spaceofmiah runs Windows but @nedbat does not.
@mpbrown, do you use Windows too ?

@Temeez
Copy link

Temeez commented Jan 6, 2020

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.

@jpmckinney
Copy link

jpmckinney commented Jan 7, 2020

Same, using coverage==5.0.2. Like others, coverage 4.5.4 works. Python is:

Python 3.6.1 (default, Jun 14 2017, 18:29:17) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin

Whereas the other reports seem to be WIndows, I'm on macOS Catalina. uname -a:

Darwin bluebell.local 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov  9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

To reproduce in my environment:

# I don't think it matters that I use pyenv. Create the virtualenv however you want.
pyenv virtualenv coveragepy
pyenv activate coveragepy

pip install coverage==5.0.2 Django==3.0
django-admin startproject coveragepytest
cd coveragepytest

coverage run --source coveragepytest manage.py test
# Can also try `coverage run --source='.' manage.py test`, etc.

Outputs:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/commands/test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/test/utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
    self._setup(name)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Users/james/.pyenv/versions/3.6.1/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coveragepytest'
Coverage.py warning: No data was collected. (no-data-collected)

@tritium21
Copy link

Alex@TOXIN C:\devel
$ py -3.6 -m venv env

Alex@TOXIN C:\devel
$ .\env\Scripts\activate

(env) Alex@TOXIN C:\devel
$ pip install coverage==5.0.2 Django==3.0
Collecting coverage==5.0.2
  Downloading https://files.pythonhosted.org/packages/06/77/2e947dadbdf9d3fb37af05f3ba9a246ff1161cde5e82f802b8d9ed7b832a/coverage-5.0.2-cp36-cp36m-win_amd64.whl (205kB)
    100% |████████████████████████████████| 215kB 4.9MB/s
Collecting Django==3.0
  Downloading https://files.pythonhosted.org/packages/43/d6/0aed0b12c66527748ce5a007da4618a65dfbe1f8fca82eccedf57d60295f/Django-3.0-py3-none-any.whl (7.4MB)
    100% |████████████████████████████████| 7.4MB 3.4MB/s
Collecting pytz (from Django==3.0)
  Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
    100% |████████████████████████████████| 512kB 8.5MB/s
Collecting sqlparse>=0.2.2 (from Django==3.0)
  Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Collecting asgiref~=3.2 (from Django==3.0)
  Downloading https://files.pythonhosted.org/packages/a5/cb/5a235b605a9753ebcb2730c75e610fb51c8cab3f01230080a8229fa36adb/asgiref-3.2.3-py2.py3-none-any.whl
Installing collected packages: coverage, pytz, sqlparse, asgiref, Django
Successfully installed Django-3.0 asgiref-3.2.3 coverage-5.0.2 pytz-2019.3 sqlparse-0.3.0
You are using pip version 18.1, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(env) Alex@TOXIN C:\devel
$ django-admin startproject coveragepytest

(env) Alex@TOXIN C:\devel
$ cd coveragepytest\

(env) Alex@TOXIN C:\devel\coveragepytest
$ coverage run --source coveragepytest manage.py test
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "c:\devel\env\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\devel\env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\devel\env\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\devel\env\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\devel\env\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\devel\env\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\devel\env\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\devel\env\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\devel\env\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\devel\env\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coveragepytest'
Coverage.py warning: No data was collected. (no-data-collected)

(env) Alex@TOXIN C:\devel\coveragepytest
$ dir
 Volume in drive C has no label.
 Volume Serial Number is B6EF-7E7F

 Directory of C:\devel\coveragepytest

01/08/2020  05:59 AM    <DIR>          .
01/08/2020  05:59 AM    <DIR>          ..
01/08/2020  05:59 AM            53,248 .coverage
01/08/2020  05:59 AM    <DIR>          coveragepytest
01/08/2020  05:59 AM               655 manage.py
               2 File(s)         53,903 bytes
               3 Dir(s)  85,808,148,480 bytes free

(env) Alex@TOXIN C:\devel\coveragepytest
$ dir coveragepytest\
 Volume in drive C has no label.
 Volume Serial Number is B6EF-7E7F

 Directory of C:\devel\coveragepytest\coveragepytest

01/08/2020  05:59 AM    <DIR>          .
01/08/2020  05:59 AM    <DIR>          ..
01/08/2020  05:59 AM               421 asgi.py
01/08/2020  05:59 AM             3,230 settings.py
01/08/2020  05:59 AM               777 urls.py
01/08/2020  05:59 AM               421 wsgi.py
01/08/2020  05:59 AM                 0 __init__.py
               5 File(s)          4,849 bytes
               2 Dir(s)  85,808,132,096 bytes free

(env) Alex@TOXIN C:\devel\coveragepytest
$

@nedbat
Copy link
Owner

nedbat commented Jan 8, 2020

@jpmckinney Thanks, I was finally able to reproduce it myself. Ironically, this turned out to be the important bit:

# I don't think it matters that I use pyenv. Create the virtualenv however you want.
pyenv virtualenv coveragepy
pyenv activate coveragepy

It wasn't until I used pyenv and pyenv-virtualenv that the problem appeared for me. Now to work on a fix....

@nedbat
Copy link
Owner

nedbat commented Jan 9, 2020

For those facing this problem: a work-around seems to be to use "python -m coverage run (etc)" instead of "coverage run (etc)".

@hugovk
Copy link
Contributor

hugovk commented Jan 10, 2020

Not sure if this is the same problem: psf/black#1227.

Black runs coverage run tests/test_black.py on GitHub Actions for Python 3.6, 3.7 and 3.8 on Ubuntu, macOS and Windows.

For some reason, the new Coverage.py version 5 is failing on Windows for Python 3.6 and 3.7.

Run coverage run tests/test_black.py
Traceback (most recent call last):
  File "tests/test_black.py", line 1788, in <module>
    unittest.main(module="test_black")
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\unittest\main.py", line 64, in __init__
    self.module = __import__(module)
ModuleNotFoundError: No module named 'test_black'
##[error]Process completed with exit code 1.

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 coverage<5 for 3.6-3.7 on Windows is a workaround.

@nedbat
Copy link
Owner

nedbat commented Jan 10, 2020

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:

pip install git+https://github.com/nedbat/coveragepy@nedbat/fix-862#egg=coverage==0.0

/cc @hugovk @tritium21 @rly @jpmckinney @spaceofmiah @Temeez @mpbrown @obi-jerome

@hugovk
Copy link
Contributor

hugovk commented Jan 10, 2020

@nedbat
Copy link
Owner

nedbat commented Jan 11, 2020

@hugovk Thanks! Any other people with data points?

@rly
Copy link

rly commented Jan 11, 2020

@nedbat That fixed it! Thanks!!

@nedbat
Copy link
Owner

nedbat commented Jan 12, 2020

This is now available in 5.0.3: https://pypi.org/project/coverage/5.0.3/

@hugovk
Copy link
Contributor

hugovk commented Jan 12, 2020

@Ravi9562
Copy link

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Python\Python37\lib\threading.py", line 870, in run
self._target(*self.args, **self.kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 76, in raise_last_exception
raise exception[1]
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management_init
.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django_init
.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "C:\Python\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 953, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'Testdjango'

Traceback (most recent call last):
File "manage.py", line 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management_init_.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 599, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 584, in start_django
reloader.run(django_main_thread)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 299, in run
self.run_loop()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 305, in run_loop
next(ticker)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 345, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 361, in snapshot_files
for file in self.watched_files():
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 260, in watched_files
yield from iter_all_python_module_files()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "C:\Python\Python37\lib\pathlib.py", line 1161, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\Python\Python37\lib\pathlib.py", line 200, in resolve
return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: ''

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

@jericore
Copy link

jericore commented Apr 2, 2020

Hey @Ravi9562 we have same problem, please tell me if u have done with this problem. i really" help

@rly
Copy link

rly commented Apr 2, 2020

@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!

@Mansouri147
Copy link

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.

@smartworld-dm
Copy link

For those facing this problem: a work-around seems to be to use "python -m coverage run (etc)" instead of "coverage run (etc)".

A great solution for running coverage on Local.

@herronelou
Copy link

Hello.
Sorry to post in this old thread, I was wondering if upon installing coverage via pip the python executable might get hardcoded somewhere? (Using coverage 5.5 if relevant)
I am also running in the case where I need to use python -m coverage run in order to pick up the right python executable.
I am using a package manager called rez (https://github.com/nerdvegas/rez) which allows to build environments on demand, similar to a virtual env.
I create an environment using a different python interpreter. Typing "python" brings the right one, yet coverage run seems to load C:\Python27.
I wasn't able to find how that might be happening, I opened up the coverage.exe and there seemed to be no specific python executable listed. Any pointers?

@herronelou
Copy link

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.

@silentjay
Copy link

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 .coveragerc and into pyproject.toml. Hope this helps other django devs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests