无法在命令行上导入模块

时间:2013-12-23 10:32:11

标签: python import module

在pip安装之后,在python中我可以导入这个module如果我以交互方式启动终端,但是我收到错误:

ImportError: cannot import name HN

如果我将所有内容保存在.py文件中并从命令行运行它。 为什么这样,我该如何解决?

感谢。

代码:

from hn import HN

hn = HN()

# print the first 2 pages of newest stories
for story in hn.get_stories(story_type='newest', page_limit=2):
    print story.rank, story.title 

0 个答案:

没有答案