5

I am having significant trouble installing psycopg2 in OSX. After installing Postgresql 9.5.4_1 using homebrew I attempted to install psycopg2 in my virtual environment: pip install psycopg2

I have also added pg_config to my path using PATH=$PATH:/usr/local/Cellar/postgresql/9.5.4_1/bin/pg_config

Upon excecution I receive a number of errors including:

  ld: library not found for -lssl


 clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'clang' failed with exit status 1

And

Failed building wheel for psycopg2

And

Command "/Users/*username*/.virtualenvs/report/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-build-cuplxne2/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-8gbk007q-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/*username*/.virtualenvs/report/bin/../include/site/python3.5/psycopg2" failed with error code 1 in /private/var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-build-cuplxne2/psycopg2/

Attempting to build from source results in similar errors...

Previous research and attempted solutions:

"Failed building wheel for psycopg2" - MacOSX using virtualenv and pip

How to install Psycopg2 for Python 3.5

How to install psycopg2 with "pip" on Python?

Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system

Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7

Thanks for any assistance you can provide!

Community
  • 1
  • 1
aegon52
  • 108
  • 1
  • 6
  • This seems to be an issue with Homebrew's update of for OSX sierra. I was able to finally fix this issue by uninstalling and reinstalling python 3.5 and postgresql with homebrew and then trying to install psycopg2 again. – aegon52 Nov 01 '16 at 18:25

3 Answers3

1

My way for macosx sierra

Install psycopg2 globally, and then use it in virtualenv

pip3 install psycopg2
workon my_env #i use virtualenvwrapper
toggleglobalsitepackages #Enable global site-packages

In my case psycopg2 normally installed as global package, but isn't installed in virtualenv

kromxr
  • 11
  • 2
  • Before reinstalling python3 and postgresql I couldn't install psycopg2 globally either. Now that its installed globally I can access it within in venv like you described. Thanks! – aegon52 Nov 02 '16 at 18:50
1

Mine broke with the Sierra 10.12.2 update. Reinstalled/updated the command line tools and psycopg2 installed correctly.

xcode-select --install

bah
  • 168
  • 1
  • 6
0

This seems to be an issue with Homebrew's update of for OSX sierra. I was able to finally fix this issue by uninstalling and reinstalling python 3.5 and postgresql with homebrew and then trying to install psycopg2 again.

aegon52
  • 108
  • 1
  • 6