Very aware there are similar questions out there. I have had a sift through answers but nothing seems to be working... I'll explain from the beginning so hopefully someone can help. I am using python 3.8 on mac.
As title says, trying to connect a new django project to a postgresql database. I have installed the postgresql app (as well as pgadmin 4 for monitoring). I've updated my settings.py file as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'psql1',
'USER': 'Pete',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '5432',
}
}
I've then gone into terminal to run python manage.py migrate
to make the initial migrations, but receive the following: Error loading psycopg2 module: No module named 'psycopg2'
.
Obviously, I then followed the instructions online and used pip install psycopg2-binary
, successfully installing psycopg2-binary in:
/Users/Pete/Library/Python/2.7/lib/python/site-packages (2.8.6)
and also pip3 install psycopg2-binary
, successfully installing psycopg2-binary in:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.8.6)
But I still receive the SAME error above.
Really quite stuck and would greatly appreciate any help!
Thanks.
question from:
https://stackoverflow.com/questions/65910653/connecting-django-to-postgresql-error-loading-psycopg2-module-despite-install 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…