Yampy import error: no module named 'authenticator'

Yampy import error: no module named 'authenticator'

TL;DR:Yampy 使用相对导入...是否有一些我可以更改的设置可以使其按原样工作(无需重构每个 import 在项目中)?


Windows 7, Python 3.4.3, PyCharm 2016.1.4, Yampy 1.0

应该是一个相当简单的问题 -- 希望以前有人遇到过这个问题。我关注了 quickstart guide. Someone asked the same question 一年前的信息较少,但没有答案。

我创建了一个 virtualenv,激活并安装了 yampy。那给出了下面的导入错误,所以我卸载并重新安装:

(MyVenv) C:\Users\me>pip install yampy
Collecting yampy
  Using cached yampy-1.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): requests in c:\virtual environments\myvenv\lib\site-packages (from yampy)
Installing collected packages: yampy
  Running setup.py install for yampy ... done
Successfully installed yampy-1.0

创建了以下目录:

__init__.py的内容:

"""
The official Python client for Yammer's API
"""

from authenticator import Authenticator
from client import Client
from yammer import Yammer

问题:

当我从 python shell import yampy 时,我得到以下回溯(这是来自 PyCharm shell,但命令中有同样的问题-行 shell):

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Virtual Environments\myvenv\lib\site-packages\yampy\__init__.py", line 22, in <module>
    from authenticator import Authenticator
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)

这对我来说没有任何意义,因为一切似乎都在那里。谢谢!


更新:

如果我将 _init _ 文件更改为使用绝对导入(from yampy.authenticator import .. 而不是 from authenticator import..),它可以解决眼前的问题,但会在整个项目中产生一串导入错误。是否有一些我可以更改的设置需要最少的重构?

应该先检查 GitHub:关于这个的 open issue 自 2015 年 2 月以来一直开放。显然该项目在 Python 2. 尝试分叉和更新为 Python 3..


更新: 手动修改,耗时约 5 分钟。立即导入!


更好的更新:Anthony Shaw(Github 上的 tonybaloney)发表了 a package for Python 3,名为 yampy3