作者:有些疯癫的小红帽 | 来源:互联网 | 2023-09-23 07:20
我想使用PostgreSQl与Django.我提到了this教程来安装它,当我运行这个命令时pythonmanage.pysyncdb我收到以下错误Traceback(mostre
我想使用PostgreSQl与Django.我提到了this教程来安装它,当我运行这个命令时
python manage.py syncdb
我收到以下错误
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 8, in
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/usr/local/lib/python2.7/dist-packages/django/core/management/sql.py", line 9, in
from django.db import models
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 40, in
backend = load_backend(connection.settings_dict['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 14, in
from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/creation.py", line 1, in
import psycopg2.extensions
ImportError: No module named psycopg2.extensions
我也看到了这个question并执行了这个
sudo apt-get build-dep python-psycopg2
pip install psycopg2
但是在执行此操作后我仍然会收到相同的错误
解决方法:
确保使用sudo完成所有正在安装的软件包;否则,安装可能会失败,您可能不会注意到错误消息指示失败是由于权限问题导致的.