错误:没有名为 psycopg2.extensions django postgresql 的模块
Posted
技术标签:
【中文标题】错误:没有名为 psycopg2.extensions django postgresql 的模块【英文标题】:Error: No module named psycopg2.extensions django postgresql 【发布时间】:2013-09-17 02:08:17 【问题描述】:我想在 Django 中使用 PostgreSQl。我参考了this 教程来安装它,当我运行这个命令时
python manage.py syncdb
我收到以下错误
Traceback (most recent call last):
File "manage.py", line 10, in <module>
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 <module>
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 <module>
from django.db import models
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 40, in <module>
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 <module>
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 <module>
import psycopg2.extensions
ImportError: No module named psycopg2.extensions
我也看到了这个question 并执行了这个
sudo apt-get build-dep python-psycopg2
pip install psycopg2
但是这样做后我仍然遇到同样的错误
【问题讨论】:
pip install psycopg2 真的成功运行了吗?我注意到您的初始命令使用了 sudo,但第二个命令没有。 @Josephpaetz 哈哈!你的正确人。伟大的 。谢谢它刚刚起作用..将其发布为答案 【参考方案1】:使用 sudo 确保正在安装所有软件包;否则,安装可能会失败,并且您可能不会注意到指示失败是由于权限问题导致的错误消息。
【讨论】:
还有一个帮助,你能给我一个链接,在那里我可以获得 django 应用程序开发的屏幕截图和代码。通过一些示例并尽快学习 我认为通用的答案是穿过Django tutorial 然后从那里走。 我发现它有点慢,而且他们没有举例说明,也没有任何屏幕截图,正在寻找一个类似开发网络应用程序之类的教程,例如 facebook demo以上是关于错误:没有名为 psycopg2.extensions django postgresql 的模块的主要内容,如果未能解决你的问题,请参考以下文章
错误:'没有名为'django.core.urlresolvers'的模块
原则 2:错误:类“..\..”没有名为“...”的字段或关联