postgresql 错误:Mac 上没有名为 psycopg2.extensions 的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11172924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: No module named psycopg2.extensions on Mac
提问by sinθ
When I try and run django, this is what I get:
当我尝试运行 django 时,这就是我得到的:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python manage.py runserver 8000
Error: No module named psycopg2.extensions
Process finished with exit code 1
I've found other questions with similar problems but none on a mac and none with solutions that help. I get no other errors and I installed psycopg2. Im working in PyCharm. This is my setting file (or the top part of it at least).
我发现了其他有类似问题的问题,但在 mac 上没有,也没有提供帮助的解决方案。我没有遇到其他错误,我安装了 psycopg2。我在 PyCharm 工作。这是我的设置文件(或者至少是它的顶部)。
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '---', # Or path to database file if using sqlite3.
'USER': '---', # Not used with sqlite3.
'PASSWORD': '---', # Not used with sqlite3.
'HOST': 'www.-----.com', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
采纳答案by santiagobasulto
As you can see in the source code, Django makes havy use of psycopg2.extensions module. Further, the extensions module is oficially containedin psycopg2. So, what I think is that you have installed psycopg the wrong way.
正如您在源代码中所见,Django 大量使用了 psycopg2.extensions 模块。此外,扩展模块正式包含在 psycopg2 中。所以,我认为您以错误的方式安装了 psycopg。
Here's the right location of the install page: http://initd.org/psycopg/install/
这是安装页面的正确位置:http: //initd.org/psycopg/install/
I recommend you to use virtualenv
我建议你使用virtualenv