【问题标题】:Eror importing tweepy?导入 tweepy 时出错?
【发布时间】:2017-11-18 03:07:53
【问题描述】:

我运行了这个简单的 .py:

from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
ckey = ''
csecret = ''
atoken = ''
asecret = ''

class Listener(StreanListener):
    def on_data(self, data):
        print data
        return True

    def on_error(self, status):
        print status

OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Strean(auth, Listener())
twitterStream.filter(track=["tour de france"])

我得到这个错误:

  File "twe.py", line 1, in <module>
    from tweepy import Stream
  File "/Users/Raz-mac/Documents/tweepy.py", line 1
    git clone https://github.com/tweepy/tweepy.git

我猜它与导入 tweepy 有关? 我该如何解决这个问题?

【问题讨论】:

  • 你安装了吗? git clone github.com/tweepy/tweepy.git, cd tweepy, python setup.py install
  • 谢谢大家。我正在使用 mac osx,即使我安装了 tweepy,我仍然会收到错误消息(我检查过并且我有库和 tweepy 文档)

标签: python tweepy


【解决方案1】:

您可以执行以下一组操作:

1) 安装虚拟环境(在 Linux 上): $ virtualenv env

2) 运行新的虚拟环境 $ source env/bin/activate

3) 安装 tweepy 库: (env)$ pip install tweepy

和 一切都会好起来的:

(env)$ python
>>> from tweepy import Stream
>>> 

【讨论】:

  • 嗨,我已经安装了 virtualenv 并创建了一个新环境,激活了环境并运行了相同的代码。我仍然遇到同样的错误。任何想法为什么?
猜你喜欢
  • 2017-12-31
  • 1970-01-01
  • 2013-12-29
  • 1970-01-01
  • 1970-01-01
  • 2021-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多