Currently on MacOS Monterey working with Django 4.0 and Python 3.10.0. After running the command
python3 manage.py runserver
I get this error
ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/tonyingle/.local/share/virtualenvs/total-weather-backend-nYZrqAi-/lib/python3.10/site-packages/psycopg2/_psycopg.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_PQbackendPID'
I have already installed pyscopg2 and psycog2-binary in the pipenv shell and outside of it. The weird part about it is that everything worked fine until I realized I had to configure my settings.py file to fix my cors issue and then everything went haywire.
Maybe some relevant settings in settings.py
ALLOWED_HOSTS = [
"https://total-weather-backend.herokuapp.com/", "http://127.0.0.1:8000/"]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'api',
'rest_framework',
'djoser',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
...
]
CORS_ORIGIN_ALLOW_ALL = True