tastypie - OAuthAuthentication - python-oauth2导入问题

时间:2012-03-14 10:05:15

标签: tastypie

我希望在tastypie中使用OAuthAuthentication。在我的ModelResource中,我这样做: (仅显示相关部分)

`from tastypie.authentication import OAuthAuthentication
class FooResource(ModelResource):
    class Meta:
        authentication = OAuthAuthentication()`

我得到一个错误说: 无法导入'python-oauth2'包。它需要与'OAuthAuthentication'类一起使用。

在此之前,我做了一个python-oauth的pip安装(下面),但随后,它继续上面的投诉。我是否需要在我的资源或其他任何地方执行其他操作才能明确导入此内容?

`pip install -r http://code.daaku.org/python-oauth/reqs
Obtaining urlencoding from git+git://github.com/nshah/python-urlencoding.git#egg=urlencoding (from -r http://code.daaku.org/python-oauth/reqs (line 1))
  Cloning git://github.com/nshah/python-urlencoding.git to ./src/urlencoding
  Running setup.py egg_info for package urlencoding
Obtaining oauth from git+git://github.com/nshah/python-oauth.git#egg=oauth (from -r http://code.daaku.org/python-oauth/reqs (line 2))
  Cloning git://github.com/nshah/python-oauth.git to ./src/oauth
  Running setup.py egg_info for package oauth
Requirement already satisfied (use --upgrade to upgrade): distribute in /usr/lib/python2.6/site-packages (from urlencoding->-r http://code.daaku.org/python-oauth/reqs (line 1))
Downloading/unpacking setuptools-git (from urlencoding->-r http://code.daaku.org/python-oauth/reqs (line 1))
  Downloading setuptools-git-0.4.2.tar.gz
  Running setup.py egg_info for package setuptools-git
Installing collected packages: urlencoding, oauth, setuptools-git
  Running setup.py develop for urlencoding
    Creating /usr/lib/python2.6/site-packages/urlencoding.egg-link (link to .)
    Adding urlencoding 0.0.1 to easy-install.pth file

    Installed /usr/lib/python2.6/site-packages/tastypie/src/urlencoding
  Running setup.py develop for oauth
    Creating /usr/lib/python2.6/site-packages/oauth.egg-link (link to .)
    Adding oauth 0.0.1 to easy-install.pth file

    Installed /usr/lib/python2.6/site-packages/tastypie/src/oauth
  Running setup.py install for setuptools-git
Successfully installed urlencoding oauth setuptools-git
Cleaning up...`

1 个答案:

答案 0 :(得分:0)

似乎你正在安装“python-oauth”而不是“python-oauth2”。错误清楚地表明了这一点。要解决这个问题,你应该简单地安装“python-oauth2”,这是一个与“python-oauth”不同的库。

试试这个:

pip install oauth2