curtisp
curtisp

Reputation: 2315

Tweepy update status with media -UnicodeDecodeError: 'ascii' codec can't decode error

Using Tweepy to update twitter post with photo.

Update with status alone works fine.

I am building my file name / path in Windows as follows:

path = 'C:/Users/foo/Documents/media/'
photoname = 'photo1.jpg'
filename = path + photoname

This prints out as a nicely formatted path and copied into Windows Explorer, opens the photo, so the path and photo name are correct.

However, when I execute with the filename in the update_with_media:

api.update_with_media(filename, status=tweet)

I get the following error message:

File "build/bdist.macosx-10.9-intel/egg/tweepy/api.py", line 98, in update_with_media
File "build/bdist.macosx-10.9-intel/egg/tweepy/api.py", line 747, in _pack_image
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

Any ideas on what is happening?

Thanks!

Upvotes: 1

Views: 997

Answers (1)

curtisp
curtisp

Reputation: 2315

Resolved this by updating to newer version of Tweepy. I had only recently installed Tweepy but somehow got an older version.

I was using v 2.3 and did pip install --upgrade tweepy which updated to v 3.3

The underlying issue appeared to be that Twitter had since deprecated their update status with media process so the newer version of Tweepy included those changes.

However very nice to see that Tweepy keeps their functionality the same. The function 'api.update_with_media(filename, status=tweet)' is in new version too and Tweepy simply deals with Twitter API changes 'under the hood'.

Upvotes: 1

Related Questions