kurozael / twitter-contest-bot

Will poll for Retweet Contests and retweet them. Inspired by http://www.hscott.net/twitter-contest-winning-as-a-service/
235 stars 109 forks source link

ImportError: cannot import name ReadTimeout #13

Closed thermike closed 8 years ago

thermike commented 8 years ago

Bit of a newb when it comes to Python and can't seem to fix the following error.

Any ideas why I'm unable to run python main.py?

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from TwitterAPI import TwitterAPI
  File "/usr/local/lib/python2.7/dist-packages/TwitterAPI/TwitterAPI.py", line 9, in <module>
    from requests.exceptions import ConnectionError, ReadTimeout, SSLError
ImportError: cannot import name ReadTimeout
greg5678 commented 8 years ago

sudo pip install --upgrade requests your welcome

thermike commented 8 years ago

I'd tried that but the error still occurred.

I was able to fix it with the following, which wraps the exceptions and converts it to a string so that it can be concatenated.

except Exception as e:
                                print("Could not connect to TwitterAPI - are your credentials correct?")
                                print("Exception: " + str(e))
greg5678 commented 8 years ago

check your credentials

On Thu, Apr 21, 2016 at 2:33 PM, thermike notifications@github.com wrote:

I'd tried that but the error still occurred.

I was able to fix it with the following, which wraps the exceptions and converts it to a string so that it can be concatenated.

except Exception as e: print("Could not connect to TwitterAPI - are your credentials correct?") print("Exception: " + str(e))

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/kurozael/twitter-contest-bot/issues/13#issuecomment-213056495

thermike commented 8 years ago

My credentials are definitely correct. I've tested them with the vanilla API Auth test script provided through the TwitterAPI suite and I don't get any errors.

However I get errors with this script, saying creds might be wrong, but if I make the proposed change, then the error is raised but the script continues to run and I see Tweets added to the queue and get retweeted.

greg5678 commented 8 years ago

What os are you running? If you don't mind please run these commands sudo apt-get update && sudo apt-get upgrade sudo git clone https://github.com/greg5678/twitter-contest.git cd twitter-contest sudo apt-get install python-pip sudo pip3 install TwitterAPI && sudo pip3 install apscheduler

                            sudo pip3 install setuptools --upgrade

sudo pip3 install --upgrade requests sudo mv config.json.example config.json now make the values correspond to your Twitter API credentials sudo main.py

hope it works now!

greg5678 commented 8 years ago

I made a mistake on the last line. It should be sudo python3 main.py

On Thu, Apr 21, 2016 at 5:23 PM, Greg McSwagger gregmcswagger@gmail.com wrote:

What os are you running? If you don't mind please run these commands sudo apt-get update && sudo apt-get upgrade sudo git clone https://github.com/greg5678/twitter-contest.git cd twitter-contest sudo apt-get install python-pip sudo pip3 install TwitterAPI && sudo pip3 install apscheduler

                              sudo pip3 install setuptools --upgrade

sudo pip3 install --upgrade requests sudo mv config.json.example config.json now make the values correspond to your Twitter API credentials sudo main.py

hope it works now!