Linux安装tensorflowjs遇权限错误,metadata生成失败
Linux下安装tensorflowjs权限错误的解决方法
问题场景
在Linux系统中执行tensorflowjs安装时,触发metadata生成失败,核心错误为Errno 13 Permission denied,具体报错信息如下:
Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [14 lines of output] running dist_info creating /tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info writing /tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/PKG-INFO writing dependency_links to /tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/dependency_links.txt writing requirements to /tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/requires.txt writing top-level names to /tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/top_level.txt writing manifest file '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/SOURCES.txt' listing git files failed - pretending there aren't any reading manifest file '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/SOURCES.txt' adding license file 'LICENSE' adding license file 'AUTHORS' writing manifest file '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/SOURCES.txt' creating '/tmp/pip-modern-metadata-njx28l3p/tensorstore-0.1.27.dist-info' error: [('/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/PKG-INFO', '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/PKG-INFO', "[Errno 13] Permission denied: '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/PKG-INFO'"), ('/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/dependency_links.txt', '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/dependency_links.txt', "[Errno 13] Permission denied: '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/dependency_links.txt'"), ('/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/requires.txt', '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/requires.txt', "[Errno 13] Permission denied: '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/requires.txt'"), ('/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/top_level.txt', '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/top_level.txt', "[Errno 13] Permission denied: '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/top_level.txt'"), ('/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info/SOURCES.txt', '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/SOURCES.txt', "[Errno 13] Permission denied: '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__/SOURCES.txt'"), ('/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info', '/tmp/pip-modern-metadata-njx28l3p/tensorstore.egg-info.__bkp__', "[Errno 13] Permission denied: '/tmp/pip-modern-metadata-njx28l3p/tensorstore.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.
解决方法
清理残留临时文件:手动删除报错中提到的pip临时目录,避免权限残留:
rm -rf /tmp/pip-modern-metadata-njx28l3p注意替换命令中的目录名为你实际报错里的目录路径
用户级安装规避系统权限:使用
--user参数将包安装到用户本地目录,无需系统级权限:pip install tensorflowjs --user升级pip至最新版本:旧版pip可能存在metadata处理的兼容性问题,先升级再安装:
pip install --upgrade pip pip install tensorflowjs使用虚拟环境隔离安装:创建独立虚拟环境,彻底避免系统依赖和权限冲突:
# 安装虚拟环境工具(Debian/Ubuntu系) sudo apt install python3-venv # 创建并激活虚拟环境 python3 -m venv tfjs-env source tfjs-env/bin/activate # 在虚拟环境内安装tensorflowjs pip install tensorflowjs
内容的提问来源于stack exchange,提问作者Adán André
相关产品推荐
相关产品推荐

