Reputation: 83
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.
Upvotes: 1
Views: 183
Reputation: 83
So, after a couple hours of more searching, I finally came across an answer that worked. However, I am stumped as to why this worked. Would someone be able to explain?
The process that worked:
PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
Upvotes: 1