試圖runserver
與db['ENGINE'] = 'django.db.backends.psycopg2'
我:的Django到PostgreSQL:錯誤加載psycopg2
[...]
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/psycopg2/__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
File "/usr/local/lib/python2.6/dist-packages/psycopg2-2.4.4-py2.6-linux-x86_64.egg/psycopg2/__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /usr/local/lib/python2.6/dist-packages/psycopg2-2.4.4-py2.6-linux-x86_64.egg/psycopg2/_psycopg.so: undefined symbol: Py_InitModule4_64
與'ENGINE': 'django.db.backends.postgresql_psycopg2'
我:
[...]
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 24, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: /usr/local/lib/python2.6/dist-packages/psycopg2-2.4.4-py2.6-linux-x86_64.egg/psycopg2/_psycopg.so: undefined symbol: Py_InitModule4_64
而且我不應該與Python> 2.6使用psycopg吧?
如何做這項工作的任何幫助?
自從我寫這個答案以來,我的知識增加了,現在我強烈建議熟悉virtualenvwrapper庫:https://virtualenvwrapper.readthedocs.io/en/latest/。當您進行初始設置時,通過它管理virtualenvs會更容易。 – omikron 2016-09-07 08:51:36