我Postgres.app通过删除Postgres.app桌面应用程序将www.example.com从9.6降级到9.5。
(我通过下载Postgres.app桌面应用程序下载了Postgres,并通过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应用程序中进行迁移时,路径看起来仍然指向Postgress的9.6版本
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
3条答案
按热度按时间cunj1qz11#
这为我解决了问题:
1.卸载psycopg 2
pip卸载psycopg 2
1.那就这么做
pip --无缓存目录安装-U psycopg 2
mzmfm0qo2#
我认为您的问题是当前安装的
psycopg2
版本引用了与您以前安装的postgres(/Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib
)捆绑在一起的C postgres库。尝试卸载并重新安装
psycopg2
。uqjltbpv3#
它尝试从符号链接
/opt/homebrew/opt/postgresql/lib/libpq.5.dylib
加载libpq.5.dylib
,但未找到文件,因此您需要更新它: