You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装aws-cli时遭遇pip报错,寻求解决方案

解决AWS CLI安装时的ValueError: non-local file URIs are not supported问题

问题描述

尝试使用以下命令安装AWS CLI:

sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

添加sudo -H参数后仍然失败:

sudo -H ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

两次安装均触发核心错误:

ValueError: non-local file URIs are not supported on this platform: 'file://.'

已确认pip为最新版本(23.3.1),但问题未解决。

原因分析

awscli-bundle的install脚本中使用了file://.这种相对路径的文件URI,新版pip(尤其是macOS平台)对文件URI的格式校验更严格,不支持这种非本地的相对路径写法。

解决方法

方法1:修改awscli-bundle的install脚本

  1. 打开awscli-bundle目录下的install脚本
  2. 找到_install_setup_deps函数中的pip调用行(大致在第167行附近):
    run(
        [python, '-m', 'pip', 'install', '--no-binary', ':all:', '--no-cache-dir', '--no-index', '--find-links', f'file://{path}', req]
    )
    
  3. 将f'file://{path}'替换为绝对路径写法,或者直接使用本地路径:
    • 绝对路径写法:f'file://{os.path.abspath(path)}'(需确保脚本顶部已导入import os)
    • 本地路径写法:直接用path替代(即当path为.时,使用./)
  4. 保存修改后,重新运行原安装命令。

方法2:改用官方推荐的现代安装方式

awscli-bundle是旧版安装方式,官方现在推荐更简单的安装途径:

  • macOS用Homebrew安装:
    brew install awscli
    
  • 用pip直接安装:
    pip3 install awscli --upgrade --user
    

内容的提问来源于stack exchange,提问作者Aditya Garde

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 23:32:33