我在 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 导入 openid 模块。
Python 2.7.1、Mac OS X 10.7、python-openid 2.2.5。