python - 导入错误: cannot import name 'sync'

标签 python python-3.x telethon

我正在尝试从 telethon 运行以下示例代码:

from telethon import TelegramClient, sync

# These example values won't work. You must get your own api_id and
# api_hash from https://my.telegram.org, under API Development.
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'

client = TelegramClient('session_name', api_id, api_hash)
client.start()

但我收到以下错误:

[root@server cli]# python3.6 client.py
Traceback (most recent call last):
  File "client.py", line 1, in <module>
    from telethon import TelegramClient, sync
ImportError: cannot import name 'sync'

我还尝试使用以下命令安装同步:

pip3.6 install sync

对这个问题有什么想法吗?

最佳答案

结果发现软件包安装已损坏。因此,我重新安装了该软件包,现在一切正常。

卸载电视马拉松:

pip uninstall telethon

然后再次安装:

pip install telethon

关于python - 导入错误: cannot import name 'sync' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51068439/

相关文章:

python - 如何在 Python 中将列或行矩阵转换为对角矩阵?

python - celery 不采摘 CELERY_ALWAYS_EAGER 设置

python - 如何使用电视马拉松从消息中的超链接中提取链接?

telegram - 如何从 Telethon 中的 MessageService 对象获取 Message 对象

Python:从时间戳中添加或删除时区小时并获取实际时间

python - 在 CentOS 上运行 Python 脚本作为后台任务

python - ‘NoneType’的对象没有len()-错误

python - 类型错误 : expected string or buffer python re. 搜索

python - 如何在 Python 中拆分一个长的 f 字符串?

python - 获取调用方法的对象