带有媒体的 Tweepy 更新状态 -UnicodeDecodeError: 'ascii' 编解码器无法解码错误 [英] Tweepy update status with media -UnicodeDecodeError: 'ascii' codec can't decode error

查看:31
本文介绍了带有媒体的 Tweepy 更新状态 -UnicodeDecodeError: 'ascii' 编解码器无法解码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Tweepy 更新带有照片的 Twitter 帖子.

Using Tweepy to update twitter post with photo.

单独使用状态更新工作正常.

Update with status alone works fine.

我正在 Windows 中构建我的文件名/路径,如下所示:

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

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

这会打印出格式良好的路径并复制到 Windows 资源管理器中,打开照片,因此路径和照片名称是正确的.

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

但是,当我使用 update_with_media 中的文件名执行时:

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

api.update_with_media(filename, status=tweet)

我收到以下错误消息:

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?

谢谢!

推荐答案

通过更新到更新版本的 Tweepy 解决了这个问题.我最近才安装了 Tweepy,但不知何故得到了一个旧版本.

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

我使用的是 v 2.3 并执行了 pip install --upgrade tweepy 更新到 v 3.3

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

潜在的问题似乎是 Twitter 从那时起就弃用了其媒体流程的更新状态,因此较新版本的 Tweepy 包含了这些更改.

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.

但是很高兴看到 Tweepy 保持其功能不变.函数api.update_with_media(filename, status=tweet)"也在新版本中,Tweepy 只是在幕后"处理 Twitter API 更改.

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'.

这篇关于带有媒体的 Tweepy 更新状态 -UnicodeDecodeError: 'ascii' 编解码器无法解码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆