从sqlite3切换到Django App的postgres - 2):未加载库:/usr/local/lib/libpq.5.dylib

时间:2016-01-14 04:11:48

标签: python django postgresql sqlite

对于那些有类似问题的人,我已经在stackoverflow上做了一些事情,但是这个错误刚刚出现。

我甚至尝试重启,命令+ R,然后设置csrutil disable。

然后重新启动,运行python manage.py makemigrations。

看来它在/ usr / local / lib /中看起来是'libpq.5.dylib',但它在我的计算机上存在于/usr/lib/libpq.5.6.dylib。

哪个位置正确?我应该把它复制一遍吗?

错误:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 324, in execute
    django.setup()
  File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Library/Python/2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/bchuey/Desktop/portfolio_projects/kallaroo/kallaroo/kallaroo/apps/accounts/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/Library/Python/2.7/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 108, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 299, in add_to_class
    value.contribute_to_class(cls, name)
  File "/Library/Python/2.7/site-packages/django/db/models/options.py", line 263, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 212, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 116, in load_backend
    return import_module('%s.base' % backend_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Library/Python/2.7/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Library/Python/2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /usr/local/lib/libpq.5.dylib
  Referenced from: /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
  Reason: image not found

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'my_db',
        'USER': 'admin',
        'PASSWORD': 'mypassword',
        'HOST': 'localhost',
        'PORT': '',
    }
}

0 个答案:

没有答案