Tweepy Error: Failed to send request



When I try to run basic hello tweepy,

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

public_tweets = api.home_timeline()
for tweet in public_tweets:
print tweet.text

I get the following error,

tweepy.error.TweepError: Failed to send request: ‘module’ object has no attribute ‘HTTPMessage’

But when my friend was able to run the same script without any errors but it’s from another IP address.
Any ideas what might be causing this error just for me?


(Edited to remove username mentions - don’t do that unless responding specifically to someone, since not everyone has the same skills or time to reply)


Most likely something wrong with python package install / environment.

pip install --upgrade --force-reinstall tweepy

might work!

(I know tweepy definitely works on top of Conda if there’s any other missing dependencies or something)


@IgorBrigadir Thank you! I tried your fix, but unfortunately, it still throws the same error.

But I found out that the error is raising from tweepy’s . Below is the error,


Strange - tweepy depends on requests, requests_oauthlib, six - if those aren’t installed it might be throwing errors.

Try installing with:
pip install git+

I notice it’s python 2.7: I’m using python 3.5 with tweepy and everything seems to be working fine. Not sure if that’s any help.


Sorry, that didn’t work too. Is it may be because my IP is blocked? If that’s the case, how to check that my IP is blocked? It was working perfectly fine till few days back. After that I didn’t disturb tweepy installation, but suddenly it starts throwing this error.

I tried installing it from git as you mentioned but it throws this error:

Btw, could you please tell me how to make tweepy use python3.5 instead of 2.7? Maybe that could work.


No, “‘module’ has no attribute” type errors are definitely nothing to do with Twitter API. It’s a python issue.

Looks like previous command was trying to install system wide, and didn’t work properly…

I’d recommend installing conda (either 2.7 or 3.5) and then installing tweepy with pip once you have a conda environment instead of installing packages system wide. It definitely works with that.


@IgorBrigadir Thank you very much my dear friend :smiley:
was able to solve the issue after installing Anaconda 3.4 and then

pip3 install tweepy

Have a nice day!