In one of my recent Django based projects, I happened to use PostgreSQL as Database Backend. In order to connect the db and for other operations with PostgreSQL, python's psycopg2 module is pretty popular and readily used. Psycopg2 got easily installed on the Linux (Ubuntu) machine but I faced some issues when I tried to install it on my Mac OS X 10.6.7. After following several tips and reading several blog posts, I finally managed to find the actual working solution which resolved the issues of installing Psycopg2 on Mac OS X. I also noticed that many people were trying to find solution of the same issues which I faced. So I am writing their solutions in a single blog post in a descriptive and step-by-step manner. There are basically two most common issues which I also faced while installing psycopg2 on Mac OS X:
PROBLEM 1:
When I tried to install psycopg2 on Mac OS X and entered following command on my terminal:
>pip install psycopg2
I got an error that pg_config file's path is not specified. Following is the full trace:
TRACE:
Error: pg_config executable not found. Please add the directory containing pg_config to the PATH or specify the full executable path with the option: python setup.py build_ext --pg-config /path/to/pg_config build ... or with the pg_config option in 'setup.cfg'. ---------------------------------------- Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/psycopg2
SOLUTION OF PROBLEM 1:
Provided that some version of PostgreSQL is already installed, you will have to explicitly add the PATH of pg_config file in your PostgreSQL bin folder. In my case, the installation PATH for PostgreSQL is:
/opt/local/lib/postgresql91/
so to define the PATH of pg_config file, I entered following command in my terminal:
> PATH=$PATH:/opt/local/lib/postgresql91/bin/
After running this command, the pg_config path error while installing psycopg2 was resolved
PROBLEM 2:
While installing psycopg2 on my Mac OS X, the pip install psycopg2 command returned following error:
lipo: can't open input file: /var/tmp//ccTy5xAu.out (No such file or directory)
Full trace of the error is as follows:
psycopg/psycopgmodule.c:951: fatal error: error writing to -: Broken pipe compilation terminated. lipo: can't open input file: /var/tmp//ccTy5xAu.out (No such file or directory) error: command 'gcc-4.2' failed with exit status 1
SOLUTION OF PROBLEM 2:
After a googling a bit, and trying several recipes, the solution that worked for me was the following command which overrides the ARCHFLAGS architecture settings:
sudo env ARCHFLAGS="-arch i386 -arch x86_64" pip install psycopg2
This command finally installed psycopg2 on my Mac OS X without any issues.
Thanks Ali, this post helped. I ran into an additional clang issue on Mavericks:
ReplyDeleteclang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
I had to modify the install command as follows to ignore the clang warning:
sudo env ARCHFLAGS="-arch i386 -arch x86_64 -Wno-error=unused-command-line-argument-hard-error-in-future" pip install psycopg2
Thanks,
ReplyDeleteI tried but I also had to add the environment variable:
export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib
Thank you!! Solution 1 was I what I needed.
ReplyDeletethân thể của lão tổ.
ReplyDeleteNhạc Thành chăm chú nhìn thấy tất cả, Long Khiếu Phượng Vũ này tựa hồ như không phải là đấu kỹ của Nhạc gia, không biết Nhạc Thiên lão tổ học được ở đâu.
Long Khiếu Phượng Vũ này cơ hồ còn mạnh hơn cả so với Long Khiếu Cửu Thiên.
Đám mây đen vốn đang tràn ngập thì có một con hoàng kim cự long và một con phượng hoàng bảy sắc xuất hiện, mây đen xung quanh bỗng nhiên biến mất, chỉ còn lại bảy sắc cầu vồng đẹp tươi.
dongtam
game mu
cho thue phong tro
http://nhatroso.com/
nhac san cuc manh
tổng đài tư vấn luật
http://dichvu.tuvanphapluattructuyen.com/
văn phòng luật
tổng đài tư vấn pháp luật
thành lập công ty
http://we-cooking.com/
chém gió
trung tâm ngoại ngữ
Dưới sắc màu tươi đẹp này không gian bỗng nhiên sáng ngời lên.
Điều khiến cho mọi người rung động chính là kim long hư ảnh cùng với phượng hoàng bảy sắc có một cái khe không gian bị xé rách, khí tức gào thét.
- Ngao.
Từng thanh âm vang lên, con phượng hoàng bay lên trên không trung, điên cuồng đánh về phía
Thanks. I have wasted ages on this today and this is the first post I have come across that fixes my issue
ReplyDeleteBefore you hire someone for your app development project, it will be good that you chalk out a set of questions for the developer. Edknt Media
ReplyDeleteComing up with great Instagram captions every day can be hard. We make that job easy for you with the best instagram captions for couples apps for both Android and iOS.
ReplyDeleteFlutter Programming is one of the most popular in the cross platforms industry. We build excellent Flutter Development Company and also learn how to overcome performance issues. is the best choice for all startups to discuss and get their project quotation. We also enable many startups to do Proof of concept and help them to learn about business decisions.
ReplyDeleteAs web app development company it is important for us to find new websites and understand about it from design to development.
ReplyDeleteweb design company in toronto
But, Python on the other hand was specifically developed keeping in mind newcomers. Even to the eye of a layman, it will seem meaningful and easy to understand. unindent does not match any outer indentation level python
ReplyDeleteThank you!! Solution is what I needed.
ReplyDeleteaccount based sales development
research for office
ReplyDeletebusiness marketers
professional ghostbook writer
Hi there, yes this post is genuinely nice and I have learned lot,of things from it on the topic of blogging.
ReplyDelete야설
대딸방
횟수 무제한 출장
스포츠마사지
바카라사이트
If you are planning to study or work abroad then you have to take the IELTS test to prove your English language efficiency. Then you have to join the best IELTS Coaching in Delhi for the preparation IELTS test. We aim to develop the student completely. Hence, Multilingua gives training for all the four sections of IELTS, that is, reading, writing, listening, and speaking. All the courses and training are majorly crafted to make you shine in your exam. Mastering all four sections will help you gain a good pointers.
ReplyDelete