嘿伙计们,当我安装了corsheaders时,我得到以下错误,任何想法为什么我得到以下错误消息,因为我没有想法。
installed:
Python 3.7.2
certifi==2018.11.29
chardet==3.0.4
Django==2.1.7
django-cors-headers==2.4.0
django-mssql==1.8
django-oauth-toolkit==1.2.0
djangorestframework==3.9.1
idna==2.8
oauthlib==3.0.1
pytz==2018.9
requests==2.21.0
urllib3==1.24.1
(Oauth) C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth>Scripts\python.exe mysite\manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03AC8C48>
Traceback (most recent call last):
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\core\management\__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\apps\registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\michael.mountford\OneDrive\Programming\matt-mikes-practice\Oauth\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'corsheaders'
你必须在你的corsheaders
中添加settings.INSTALLED_APPS
在我的情况下,即使我在settings.INSTALLED_APPS中有corsheaders,我也遇到了同样的问题。我的问题的原因是,我没有运行虚拟环境,在我启动之后,问题就消失了。也许它会对任何人有所帮助。