Reply to Tweet with Tweepy – Python

Just posting the solution so no someone else suffers the way I did. Twitter updated the API and added an option named auto_populate_reply_metadata All you need to do is set that to true, and the leave the rest as should be. Here is a sample: api.update_status(status=”your reply”, in_reply_to_status_id = tweetid , auto_populate_reply_metadata=True) Also, the status_id … Read more

How do I extend a python module? Adding new functionality to the `python-twitter` package

A few ways. The easy way: Don’t extend the module, extend the classes. exttwitter.py import twitter class Api(twitter.Api): pass # override/add any functions here. Downside : Every class in twitter must be in exttwitter.py, even if it’s just a stub (as above) A harder (possibly un-pythonic) way: Import * from python-twitter into a module that … Read more

Managing Tweepy API Search

I originally worked out a solution based on Yuva Raj’s suggestion to use additional parameters in GET search/tweets – the max_id parameter in conjunction with the id of the last tweet returned in each iteration of a loop that also checks for the occurrence of a TweepError. However, I discovered there is a far simpler … Read more

Avoid Twitter API limitation with Tweepy

For anyone who stumbles upon this on Google, tweepy 3.2+ has additional parameters for the tweepy.api class, in particular: wait_on_rate_limit – Whether or not to automatically wait for rate limits to replenish wait_on_rate_limit_notify – Whether or not to print a notification when Tweepy is waiting for rate limits to replenish Setting these flags to True … Read more

Python3 UnicodeDecodeError with readlines() method

I think the best answer (in Python 3) is to use the errors= parameter: with open(‘evil_unicode.txt’, ‘r’, errors=”replace”) as f: lines = f.readlines() Proof: >>> s = b’\xe5abc\nline2\nline3′ >>> with open(‘evil_unicode.txt’,’wb’) as f: … f.write(s) … 16 >>> with open(‘evil_unicode.txt’, ‘r’) as f: … lines = f.readlines() … Traceback (most recent call last): File “<stdin>”, … Read more

Convert Tweepy Status object into JSON

The Status object of tweepy itself is not JSON serializable, but it has a _json property which contains JSON serializable response data. For example: >>> status_list = api.user_timeline(user_handler) >>> status = status_list[0] >>> json_str = json.dumps(status._json)

No module named pip.req

This is happening lately because of a change in pip 10. The fix is pretty easy. You probably have something like: from pip.req import parse_requirements Change that to something like: try: # for pip >= 10 from pip._internal.req import parse_requirements except ImportError: # for pip <= 9.0.3 from pip.req import parse_requirements That should do it.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)