简体   繁体   中英

Django can't find libssl on OS X Mavericks

I'm trying to get Django running on OS X Mavericks and I've encountered a bunch of errors along the way, the latest way being that when run python manage.py runserver to see if everything works, I get this error, which I believe means that it misses libssl:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: @loader_path/../lib/libssl.1.0.0.dylib Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so Reason: image not found

I have already upgraded Python to 2.7.6 with the patch that handles some of the quirks of Mavericks.

Any ideas?

Full traceback:

Unhandled exception in thread started by > Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 93, in inner_run self.validate(display_num_errors=True) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 280, in validate num_errors = get_validation_errors(s, app) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/validation.py", line 28, in get_validation_errors from django.db import models, connection File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/ init .py", line 40, in backend = load_backend(connection.settings_dict['ENGINE']) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/ init .py", line 34, in getattr return getattr(connections[DEFAULT_DB_ALIAS], i tem) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 93, in getitem backend = load_backend(db['ENGINE']) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 27, in load_backend return import_module('.base', backend_name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module import (name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 14, in from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/creation.py", line 1, in import psycopg2.extensions File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/ init .py", line 50, in from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: @loader_path/../lib/libssl.1.0.0.dylib Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so Reason: image not found

This worked for me.

brew unlink openssl && brew link openssl --force

This will recreate correctly all the links to libssl 1.0 which was already installed.

psycopg2 is missing. Postgresql database adapter for Python.

You need to reinstall Postgresql. You're on a mac, so install it using brew .

brew install postgresql

If brew outputs that it's already installed, uninstall it and reinstall it again.

It seems that it's libssl.1.0.0.dylib that is missing. Mavericks comme with libssl 0.9.8 . You need to install libssl via homebrew.

If loaderpath points to /usr/lib/ , you also need to symlink libssl from /usr/local/Cell/openssl/lib/ into /usr/lib .

This problem happened to me because I was using posqgressapp . This is probably related to sandboxing.

Delete the posqgressapp and install postgress using brew solved my problem.

Install Postgress using HomeBrew:
http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/

Unable to open psql on Mavericks:
https://github.com/PostgresApp/PostgresApp/issues/137

Installing the full PostgreSQL server on my OSX laptop bothers me. Uninstall is clunky and now you have a pretty rocking DB server just sitting unused just for the libraries.

I know others have posted against using Postgres.app but I love it. Its clean and easy to use. The key is to remember that its just a folder with all the necessary libraries inside to help when building Psycopg2 on your OSX box. Just make sure add something to your path so you can find the libraries like:

$ PATH=$PATH:/Applications/Postgres93.app/Contents/MacOS/bin/

(Alter, of course based upon the version of Postgres.app that you installed.)

Once you get your psycopg2 compiled you simply drag Postgres.app to the trash and its gone. Easy peasy.

I wasted a lot of time with all kind of errors and psycopg2 on both OSX & Linux, so I threw this together:

http://www.codychamberlain.com/posts/installing-psycopg2-on-osx/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM