mozillazg / python-shanbay

提供一系列操作扇贝网 (www.shanbay.com) 的 API(不再维护)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

import 时报错

hillerliao opened this issue · comments

In [3]: from shanbay import Shanbay

ImportError Traceback (most recent call last)
in ()
----> 1 from shanbay import Shanbay

ImportError: cannot import name Shanbay

In [4]:

不知道你安装的是哪个版本的 shanbay,使用的是哪个版本的 python ?刚试了一下可以正常 import:

(test)$ pip install shanbay
Collecting shanbay
  Downloading shanbay-0.3.4-py2.py3-none-any.whl
...
Installing collected packages: six, html5lib, requests, beautifulsoup4, oauthlib, requests-oauthlib, shanbay
Successfully installed beautifulsoup4-4.4.1 html5lib-0.9999999 oauthlib-1.1.1 requests-2.10.0 requests-oauthlib-0.6.1 shanbay-0.3.4 six-1.10.0
(test)$ python
Python 3.5.1 (default, Dec 28 2015, 13:12:17) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from shanbay import Shanbay
>>> 

import shanbay
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/shanbay/init.py", line 22, in
from .api import API # noqa
File "/usr/local/lib/python2.7/dist-packages/shanbay/api.py", line 9, in
from requests_oauthlib import OAuth2Session, TokenUpdated
File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/init.py", line 3, in
from .oauth2_auth import OAuth2
File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth2_auth.py", line 3, in
from oauthlib.oauth2 import is_secure_transport
ImportError: cannot import name is_secure_transport

抱歉,之前是我文件命名与模块名重名了。不过现在是这个问题。

看报错信息应该是 oauthlib 或 requests_oauthlib 的版本问题,试试安装最新版本的 oauthlib 和 requests_oauthlib 。