Termux中pip安装Telethon/Pyrogram失败,请求解决方案
Termux中安装Telethon/Pyrogram的权限错误解决方案
在Termux环境下使用pip安装Telethon或Pyrogram时,出现**权限拒绝(Errno 13)**错误,导致无法生成包元数据。具体报错信息如下:
~ $ pip install telethon Collecting telethon Downloading Telethon-1.28.5-py3-none-any.whl (600 kB) ━━━━━━━━━━━━━━ 600.9/600.9 284.4 kB/s eta 0:00:00 kB Collecting pyaes (from telethon) Downloading pyaes-1.6.1.tar.gz (28 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [1 lines of output] error: [('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info/PKG-INFO', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/PKG-INFO', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/PKG-INFO'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info/dependency_links.txt', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/dependency_links.txt', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/dependency_links.txt'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info/top_level.txt', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/top_level.txt', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/top_level.txt'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info/SOURCES.txt', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/SOURCES.txt', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__/SOURCES.txt'"), ('/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__', "[Errno 13] Permission denied: '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-slc24ohr/pyaes.egg-info.__bkp__'")] [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
已尝试以下命令但无效:
pkg install python-pip pip install pyrogram pip3 install pyrogram MATHLIB="m" pip install pyrogram
解决方案
1. 清理pip缓存与临时文件残留
权限错误大概率是pip临时目录的缓存文件损坏或权限异常导致,先清理:
# 清理pip缓存 pip cache purge # 删除Termux临时目录下的pip残留文件 rm -rf /data/data/com.termux/files/usr/tmp/pip-*
2. 使用用户级权限安装(推荐)
Termux中不建议全局安装Python包,使用--user参数将包安装到用户专属目录,避免权限问题:
# 安装Telethon pip install --user telethon # 安装Pyrogram pip install --user pyrogram
3. 更新Termux系统与依赖
确保Termux系统及所有组件为最新版本,避免兼容性问题:
pkg update && pkg upgrade -y # 重新安装python-pip确保完整性 pkg reinstall python-pip -y
4. 手动安装依赖包
如果仍因pyaes依赖报错,先单独安装pyaes再装目标包:
pip install --user pyaes # 再安装Telethon/Pyrogram pip install --user telethon
内容的提问来源于stack exchange,提问作者Alisher Xurramov
相关产品推荐
相关产品推荐

