找不到模块'corsheaders' django/heroku deploy
Posted
技术标签:
【中文标题】找不到模块\'corsheaders\' django/heroku deploy【英文标题】:No module found 'corsheaders' django/heroku deploy找不到模块'corsheaders' django/heroku deploy 【发布时间】:2019-02-18 10:56:11 【问题描述】:没有其他答案对我有用。我已经完成了pipenv install django-cors-headers
、pipenv install psycopg2-binary
等,直到我的手指起泡无济于事......
如果您不介意看的话,这会有点长;提前谢谢...
*settings.py*
# Application definition
INSTALLED_APPS = [
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
'quizzes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
这是正确级别的 Pipfile...
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[requires]
python_version = "3.6"
[packages]
python-decouple = "*"
"psycopg2" = "*"
django-dotenv = "*"
gunicorn = "*"
whitenoise = "*"
dj-database-url = "*"
djangorestframework = "*"
django = "*"
django-cors-headers = "*"
"psycopg2-binary" = "*"
[dev-packages]
但我仍然从 ./manage.py 获得回溯 line 17
,最终没有名为“corsheaders”的模块......我已经卸载/重新安装了所有内容。有人有什么想法吗?
【问题讨论】:
你最后找到答案了吗?我也面临同样的问题... 【参考方案1】:我遇到了类似的问题 - 尝试使用 pip3/pip/pipenv 安装 django-cors-headers
。它为我解决了这个问题。
【讨论】:
对答案不明确的建议应作为评论发布以上是关于找不到模块'corsheaders' django/heroku deploy的主要内容,如果未能解决你的问题,请参考以下文章
Python Django错误ModuleNotFoundError:没有名为'corsheaders'的模块[关闭]