错误导入tweepy?

时间:2017-06-15 14:50:04

标签: python tweepy

我运行了这个简单的.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有关吗? 我怎么能解决这个问题?

1 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

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

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

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

和 一切都会好的:

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