Reputation: 23
Hello I'm receiving the following error when trying to run a script in Ubuntu to stream tweets from twitter. I'm new to programing and I don't understand what's wrong. I've did sudo apt-get install python-twitter already and sudo apt-get upgrade.
computer@ubuntu:~/Desktop/Twitter/examples$ python stream_tweets.py
Traceback (most recent call last):
File "stream_tweets.py", line 1, in <module>
from TwitterAPI import TwitterAPI
File "/usr/local/lib/python2.7/dist-packages/TwitterAPI/TwitterAPI.py", line 10, in <module>
from requests.packages.urllib3.exceptions import ReadTimeoutError, ProtocolError
ImportError: cannot import name ReadTimeoutError
Upvotes: 0
Views: 2927
Reputation: 23
I found the answer ! All I have to do is update request and it's working !
pip install --upgrade requests
To install requests it's pip install requests
Upvotes: 1
Reputation: 312
I think you may be looking at the wrong thing. When you install python-twitter
as an Ubuntu package, it is not the same as using the python-twitter
Python package. To confirm this, I listed the actual Ubuntu package contents. I am running Ubuntu 12.04.5 LTS version:
tbates@ubuntu-desktop-1:~$ dpkg-query -L python-twitter
/.
/usr
/usr/bin
/usr/bin/tweet
/usr/bin/twitter-to-xhtml
/usr/share
/usr/share/doc
/usr/share/doc/python-twitter
/usr/share/doc/python-twitter/twitter.html
/usr/share/doc/python-twitter/copyright
/usr/share/doc/python-twitter/changelog.Debian.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/tweet.1.gz
/usr/share/man/man1/twitter-to-xhtml.1.gz
/usr/share/pyshared
/usr/share/pyshared/python_twitter-0.6.egg-info
/usr/share/pyshared/python_twitter-0.6.egg-info/dependency_links.txt
/usr/share/pyshared/python_twitter-0.6.egg-info/SOURCES.txt
/usr/share/pyshared/python_twitter-0.6.egg-info/top_level.txt
/usr/share/pyshared/python_twitter-0.6.egg-info/requires.txt
/usr/share/pyshared/python_twitter-0.6.egg-info/PKG-INFO
/usr/share/pyshared/twitter.py
/usr/share/python-support
/usr/share/python-support/python-twitter.public
Doing a man tweet
seems to indicate this package provides command line tools for sending tweets, and not so much for how to stream tweets.
If you meant to use the python-twitter
package, I suggest you follow the directions at the GitHub repository, located at https://github.com/bear/python-twitter. If you want to use the streaming API, I have not done that myself, but a there was a great article I found discussing how to do it at http://adilmoujahid.com/posts/2014/07/twitter-analytics/. It seems like Twitter's documentation is pretty spread out, and there very canonical or clear about how to "just do it," so you are not alone! Hope this helps.
Upvotes: 0