Skip to content
This repository has been archived by the owner on Feb 15, 2021. It is now read-only.

ModuleNotFoundError: No module named corsheaders.middleware #42

Open
rowanv opened this issue Feb 1, 2019 · 2 comments
Open

ModuleNotFoundError: No module named corsheaders.middleware #42

rowanv opened this issue Feb 1, 2019 · 2 comments

Comments

@rowanv
Copy link

rowanv commented Feb 1, 2019

Hi,

Thanks for forking this and maintaining it given the lack of updates on django-cors-headers. I'm finding that when I follow the installation instructions in the README.md, I get an error that seems to indicate that django-cors-middleware by itself is missing some sort of dependency. When I install both django-cors-headers==2.4.0 and django-cors-middleware=1.3.1, CORS issues are resolved without a problem. Any idea why this might be?

Including error that I got here, using Django==1.11.6.

======================================================================
ERROR: setUpClass (functional_tests.test_my_app.TestMyApp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rowan/workspace/beacon/beacon/functional_tests/base.py", line 19, in setUpClass
    super().setUpClass()
  File "/Users/rowan/virtualenvs/beacon/lib/python3.6/site-packages/django/test/testcases.py", line 1352, in setUpClass
    raise cls.server_thread.error
  File "/Users/rowan/virtualenvs/beacon/lib/python3.6/site-packages/django/test/testcases.py", line 1281, in run
    handler = self.static_handler(_MediaFilesHandler(WSGIHandler()))
  File "/Users/rowan/virtualenvs/beacon/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 151, in __init__
    self.load_middleware()
  File "/Users/rowan/virtualenvs/beacon/lib/python3.6/site-packages/django/core/handlers/base.py", line 80, in load_middleware
    middleware = import_string(middleware_path)
  File "/Users/rowan/virtualenvs/beacon/lib/python3.6/site-packages/django/utils/module_loading.py", line 20, in import_string
    module = import_module(module_path)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'corsheaders.middleware'
@wsgomes
Copy link

wsgomes commented Apr 17, 2020

In my case, this error happened after installing both (middleware then headers) and then removing middleware. It seems like removing middleware affects headers. To fix, just uninstall both and install one again.

@jamrod
Copy link

jamrod commented Jun 26, 2020

I had a similar error, "ModuleNotFoundError: No module named 'corsheaders'"
I had to open a terminal outside the virtual environment and install with "python -m pip install django-cors-headers" to fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants