简体   繁体   中英

No module found 'corsheaders' django/heroku deploy

None of the other answers have worked for me. Ive done pipenv install django-cors-headers , pipenv install psycopg2-binary , etc. until my fingers have blisters to no avail...

This is going to be a bit long if you don't mind looking; thanks in advance...

*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',
]

This is the Pipfile on the proper level...

[[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]

But I am still getting traceback line 17 from ./manage.py and ultimately No module named 'corsheaders'... I've uninstalled/reinstalled and everything. Anyone got any ideas?

  • edit: I'm using Ubuntu 18.04

I had a similar issue - try installing django-cors-headers with pip3/pip/pipenv. It solved the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM