【问题标题】:Import error with python-openid in django在 django 中使用 python-openid 导入错误
【发布时间】:2012-05-07 21:22:50
【问题描述】:

我在 django 项目中使用 python-openid 时遇到问题。如果从 openid 模块导入任何内容,我会在运行时收到异常。

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.4
Python Version: 2.7.1
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in resolve
  298.             for pattern in self.url_patterns:
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in url_patterns
  328.         patterns = getattr(self.urlconf_module, "urlpatterns",               self.urlconf_module)
  File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
    323.             self._urlconf_module = import_module(self.urlconf_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py" in import_module
    35.     __import__(name)
  File "/Users/air/Desktop/givemecoin/givemecoin/urls.py" in <module>
    2. from givemecoin.views import hello, register, new_user_welcome, profile, payment
  File "/Users/air/Desktop/givemecoin/givemecoin/views.py" in <module>
    17. from openid.store.filestore import FileOpenIDStore

  Exception Type: ImportError at /
  Exception Value: No module named consumer.consumer

但 python-openid 已正确安装在“/Library/Python/2.7/site-packages”和 python 路径中的此目录中。我可以从命令行 python 导入 o​​penid 模块。

Python 2.7.1、Mac OS X 10.7、python-openid 2.2.5。

【问题讨论】:

  • github.com/openid/python-openid/blob/master/examples/djopenid/… - 此文件尝试执行“从 openid.consumer 导入消费者”。你能在 site-packages 中搜索 consumer.py 并查看它是否存在吗?
  • @waitinfratrain 是的,在“/Library/Python/2.7/site-packages/openid”中我有消费者目录和消费者.py。这是工作'从 openid.consumer.consumer import Consumer, SUCCESS, DiscoveryFailure print SUCCESS'

标签: django macos importerror python-openid


【解决方案1】:

我在项目文件夹中有 openid.pyc。我的错。非常感谢 @waitinfratrain 的帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-18
    • 1970-01-01
    • 2012-01-31
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    • 2013-10-07
    • 1970-01-01
    相关资源
    最近更新 更多