Django can't find libssl on OS X Mavericks
我试图让Django在OS X Mavericks上运行,我遇到了一堆错误,最新的方式是当运行
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
我已经将Python升级到2.7.6,补丁处理了一些小牛队的怪癖。
有任何想法吗?
完全追溯:
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], item)
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
这对我有用。
1 | brew unlink openssl && brew link openssl --force |
这将正确地重新创建已安装的libssl 1.0的所有链接。
似乎缺少
如果loaderpath指向
psycopg2丢失了。适用于Python的Postgresql数据库适配器。
你需要重新安装Postgresql。你在Mac上,所以使用
1 | brew install postgresql |
如果brew已经安装了它,请将其卸载并重新安装。
在我的OSX笔记本电脑上安装完整的PostgreSQL服务器困扰着我。卸载是笨重的,现在你有一个非常摇摆的数据库服务器只是为图书馆闲置。
我知道其他人已发布反对使用Postgres.app但我喜欢它。它干净,易于使用。关键是要记住它只是一个包含所有必要库的文件夹,以帮助在OSX盒上构建Psycopg2。只需确保在路径中添加一些内容,这样您就可以找到以下库:
$ PATH = $ PATH:/Applications/Postgres93.app/Contents/MacOS/bin/
(当然,这取决于您安装的Postgres.app版本。)
一旦你编译了psycopg2,你只需将Postgres.app拖到垃圾箱即可。十分简单。
在OSX和OSX上,我浪费了很多时间来处理所有类型的错误和psycopg2。 Linux,所以我把它们放在一起:
http://www.codychamberlain.com/posts/installing-psycopg2-on-osx/
这个问题发生在我身上,因为我使用的是posqgressapp。这可能与沙盒有关。
删除posqgressapp并使用brew安装postgress解决了我的问题。
使用HomeBrew安装Postgress:
http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/
无法在小牛队上打开psql:
https://github.com/PostgresApp/PostgresApp/issues/137