2016-12-29 61 views
0

我通過刪除Postgres.app桌面應用程序將Postgres.app從9.6降級到9.5。我做Django指向錯誤版本的Postgres

更新數據庫(我下載的Postgres通過下載Postgres.app桌面應用程序,我做PIP安裝Django Django的安裝)

sudo /usr/libexec/locate.updatedb 

它看起來是從右邊的目錄數據庫啓動。

/Applications/Postgres.app/Contents/Versions/9.5/bin/initdb 
/Applications/Postgres.app/Contents/Versions/9.5/share/doc/postgresql/html/app-initdb.html 
/Applications/Postgres.app/Contents/Versions/9.5/share/man/man1/initdb.1 

然而,當我試圖做我的Django應用程序遷移,它看起來像路徑仍指向9.6版本Postgress

Traceback (most recent call last): 
    File "manage.py", line 22, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line 
    utility.execute() 
    File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute 
    django.setup() 
    File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/__init__.py", line 27, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate 
    app_config.import_models(all_models) 
    File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/apps/config.py", line 199, 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/me/Desktop/myapp/venv/lib/python2.7/site-packages/tenant_schemas/models.py", line 4, in <module> 
    from tenant_schemas.postgresql_backend.base import _check_schema_name 
    File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/tenant_schemas/postgresql_backend/base.py", line 14, in <module> 
    import psycopg2 
    File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in <module> 
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID 
ImportError: dlopen(/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib 
    Referenced from: /Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so 
    Reason: image not found 
+0

請更新您的問題,包括您如何安裝postgresql和django – e4c5

+0

@ e4c5剛剛更新,謝謝! – YAL

回答

2

這解決了這個問題對我來說:

  1. 卸載psycopg2

    PIP卸載psycopg2

  2. 然後做到這一點

    PIP --no-的cache dir install -U psycopg2

1

我認爲你的問題是,當前安裝的psycopg2版本引用了與您先前安裝的postgres(/Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib)捆綁在一起的C postgres庫。

嘗試卸載並重新安裝psycopg2

pip uninstall psycopg2 
pip install psycopg2 
+0

我試過這個,它仍然給了我相同的輸出 – YAL