【问题标题】:really simple pip python-twitter issue; can't import twitter非常简单的 pip python-twitter 问题;无法导入推特
【发布时间】:2012-10-15 04:17:12
【问题描述】:

我不知道我在这里做错了什么:

Sun Oct 14$ pip install python-twitter
Requirement already satisfied (use --upgrade to upgrade): python-twitter in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from python-twitter)
Requirement already satisfied (use --upgrade to upgrade): simplejson in /Library/Python/2.7/site-packages (from python-twitter)
Requirement already satisfied (use --upgrade to upgrade): oauth2 in /Library/Python/2.7/site-packages (from python-twitter)
Requirement already satisfied (use --upgrade to upgrade): httplib2 in /Library/Python/2.7/site-packages (from oauth2->python-twitter)
Cleaning up...
Sun Oct 14$ python
Python 2.7.2 (default, Nov 17 2011, 13:22:48) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import twitter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named twitter
>>> 

我需要做一个 virtualenv 吗?还有什么可能发生的?很抱歉我缺乏理解,但感谢您提供任何帮助。

编辑 #1 试图让 tweepy 工作,但是.... 可能这里有两个版本的 Python 2.7

Sun Oct 14$ pip install --upgrade tweepy
Requirement already up-to-date: tweepy in ./tweepy-1.11-py2.7.egg
Cleaning up...
Sun Oct 14$ python
Python 2.7.2 (default, Nov 17 2011, 13:22:48) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tweepy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tweepy
>>> 

我想我可能安装了两个版本的 Python 2.7;一个通过自制软件和苹果默认设置。自制软件安装是否有可能将包放在 /Library/Python/2.7/site-packages 中?

再次感谢您

【问题讨论】:

  • 你可能安装了两个版本的 Python 2.7 吗?
  • 很喜欢 tweepy 但我认为你也可能是对的
  • 在 virtualenv 中尝试;如果它有效,你有你的答案。

标签: python pip python-twitter


【解决方案1】:

来自what I've read,python-twitter:

依赖于 Twitter 关闭的 Basic-Auth 八月和九月(2010 年)。 API 仅支持 OAuth,并且 python-twitter 不支持这个。

更新:我刚刚尝试使用与您使用的完全相同的方法安装 python-twitter,但我也无法导入它。在做了一些研究后,我遇到了Python Twitter Tools,我认为这是 python-twitter 的替代品。

Installing twitter 需要安装工具。只需easy_install twitter 从网络安装即可。

【讨论】:

  • 谢谢,试图让 tweepy 工作,但仍然遇到类似的错误。嗯....关于分辨率的任何想法? Python 绝对不是我的强项
  • 其实不用pip,试试sudo esay_install twitter,它需要setuptools。 mike.verdone.ca/twitter/#install这似乎对我有用。
  • 我以前试过这个,但没有骰子,得到ImportError: No module named twitter,让我在virtualenv中看看,
  • 我猜它可能是在您的其他 Python 安装中安装模块,这就是导入失败的原因。
  • 是的,我想我有两个系统版本的 python2.7 并且站点包可能在错误的地方。创建一个 virtualenv 至少使站点包更加明确(正如您在之前的评论中所说)。谢谢斯科特
猜你喜欢
  • 2011-08-25
  • 2011-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-29
  • 2016-03-12
  • 2011-04-13
  • 1970-01-01
相关资源
最近更新 更多