9👍
Refer to official installation guide of psycopg:
Installing on Mac OS X As a first option, please consider using a
packaged version of Psycopg from Fink or MacPorts.If you still want to build Psycopg from source, take a look at these
articles.
183👍
Just would like to share. The following code worked for me:
env LDFLAGS='-L/usr/local/lib -L/usr/local/opt/openssl/lib
-L/usr/local/opt/readline/lib' pip install psycopg2==2.5.2
I am using macOS Sierra and psql 9.6.1.
I got the lib path from the pg_config
command.
- [Django]-How about having a SingletonModel in Django?
- [Django]-UUID('…') is not JSON serializable
- [Django]-In Django, how does one filter a QuerySet with dynamic field lookups?
58👍
I am using MAC OS CATALINA verison 10.15.5 with python3 and psql (PostgreSQL) 12.3. Here is what worked for me:
Try installing openssl using brew
brew install openssl
after that export these variables in the terminal.
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
verify these variables have been exported by echo $LDFLAGS
and after that you are good to go with installation of psycopg2 by typing
pip3 install psycopg2
- [Django]-UUID('…') is not JSON serializable
- [Django]-Unit testing with django-celery?
- [Django]-Name '_' is not defined
35👍
First, download Postgres.app
.
Then, before running pip install psycopg2
, put the binary in your path:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
NOTICE:
9.3
stands for version and will differ over time.
- [Django]-Django models: Only permit one entry in a model?
- [Django]-Django admin: how to sort by one of the custom list_display fields that has no database field
- [Django]-In a django model custom save() method, how should you identify a new object?
17👍
Generic LDFLAGS variable set
Just export LDFLAGS before installing it, here is generic command which shall work for OS X (and I believe any LINUX system which has same error):
LDFLAGS="$(pg_config --ldflags)" pip install psycopg2
- [Django]-Django: Error: You don't have permission to access that port
- [Django]-How to get primary keys of objects created using django bulk_create
- [Django]-How can I change the default Django date template format?
- [Django]-How do I import the Django DoesNotExist exception?
- [Django]-Django Model MultipleChoice
- [Django]-Django – "no module named django.core.management"
7👍
Install postgres
with brew
:
brew install postgres
Then, in your virtualenv install psycopg2
with this command:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install psycopg2
- [Django]-Django Migrations Add Field with Default as Function of Model
- [Django]-How to customize user profile when using django-allauth
- [Django]-How can I activate the unaccent extension on an already existing model
2👍
Focusing on this line: ld: library not found for -lpq
psycopg2, like most 3rd-party postgres libraries, wants ‘pg_config’ available in your path. I’m guessing that’s your problem.
Type ‘pg_config’ at the command prompt. I hope you see that it’s not found. If not, do a:
sudo find / -name pg_config
to find where it’s at, and then add that location to your path, run ‘pg_config’ and see it succeed, and then finally, re-run pip.
the find command is searching starting at your root dir; it will take a few minutes.
- [Django]-Django 1.4 – can't compare offset-naive and offset-aware datetimes
- [Django]-How do I convert a Django QuerySet into list of dicts?
- [Django]-How to write django test meant to fail?
2👍
I was trying so many things and nothing worked. However, if you use Xcode CLI Tools on Mojave and have a problem installing psycopg2, try the following command and try to install psycopg2 again.
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
This was described as a Mojave Issue: Pillowissue
In my case, this solved the issue.
- [Django]-Django's forms.Form vs forms.ModelForm
- [Django]-Why does Django's render() function need the "request" argument?
- [Django]-Create empty queryset by default in django form fields
- [Django]-Why does django run everything twice?
- [Django]-Django: FloatField or DecimalField for Currency?
- [Django]-Set Django's FileField to an existing file
- [Django]-Should I be adding the Django migration files in the .gitignore file?
- [Django]-Django delete superuser
- [Django]-How to add a cancel button to DeleteView in django
0👍
The following post helped me get it working:
https://stackoverflow.com/a/10326004/1361851
Had to install “command line tools” for Xcode and then I was able to pip install with the virtualenv just the same as the heroku tutorial.
- [Django]-Dynamic choices field in Django Models
- [Django]-Django content-type : how do I get an object?
- [Django]-How to submit form without refreshing page using Django, Ajax, jQuery?
0👍
I tried all of the above solutions but the only thing that resolved the issue for me is simply updating Xcode CLI utilities through the official App Store.
- [Django]-How can I get MINIO access and secret key?
- [Django]-Django datefield filter by weekday/weekend
- [Django]-Django order_by query set, ascending and descending
-1👍
Once I was also facing the same problem on Mac then I figured out that psycopg2 has a dependency on GCC library.
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
Just run this command and then try to run
pip install psycopg2
Hope this will work.
- [Django]-Paginating the results of a Django forms POST request
- [Django]-How to produce a 303 Http Response in Django?
- [Django]-Django exception middleware: TypeError: object() takes no parameters