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

MacBook Yosemite系统下AWS CLI安装失败求助

解决MacBook Yosemite上AWS CLI安装失败问题

Let's fix this installation issue step by step. The core problem here is a compatibility conflict between the outdated awscli-bundle script and your pip 19.1.1 version—pip changed how its main function is structured after version 10, which breaks the old bundle script's logic.

第一步:清理之前的安装残留

First, let's remove all leftover files from your previous attempts to avoid conflicts:

  • Delete the AWS installation directory created by the bundle script:
    sudo rm -rf /usr/local/aws
    
  • Delete the downloaded awscli-bundle folder:
    rm -rf ~/awscli-bundle
    
  • Check for any existing aws command and remove it if present:
    which aws && sudo rm $(which aws)
    

方法一:用pip3直接安装(推荐)

AWS now recommends using pip directly instead of the legacy bundle script, which will avoid the pip compatibility issue. Since you already have Python 3.7 and pip3 set up:

  1. Install AWS CLI to your user directory (no sudo needed, avoids permission problems):
    pip3 install awscli --user
    
  2. Add your user-specific Python bin directory to your PATH so the aws command is accessible globally. Edit your ~/.bash_profile:
    echo 'export PATH="$HOME/Library/Python/3.7/bin:$PATH"' >> ~/.bash_profile
    
  3. Refresh your shell environment to apply the PATH change:
    source ~/.bash_profile
    
  4. Verify the installation works:
    aws --version
    

方法二:用虚拟环境隔离安装(如果方法一仍有问题)

If you run into permission or dependency conflicts with your system Python, use a virtual environment to isolate the AWS CLI installation:

  1. Install virtualenv to your user directory:
    pip3 install virtualenv --user
    
  2. Create a dedicated virtual environment for AWS CLI:
    virtualenv -p python3.7 ~/aws-venv
    
  3. Activate the virtual environment:
    source ~/aws-venv/bin/activate
    
  4. Install AWS CLI inside the virtual environment:
    pip install awscli
    
  5. Verify the installation:
    aws --version
    
  6. To use the aws command globally without activating the virtual environment, create a symbolic link:
    sudo ln -s ~/aws-venv/bin/aws /usr/local/bin/aws
    
  7. You can exit the virtual environment anytime with:
    deactivate
    

原报错原因分析

The error ImportError: cannot import name 'main' from 'pip' happens because:

  • The awscli-bundle script uses an older version of virtualenv that expects the old pip main import pattern.
  • Your system's pip 19.1.1 uses a new structure where from pip import main is no longer valid (this changed in pip 10+).
  • The virtualenv created by the bundle script was incorrectly pulling in your user-level pip files instead of using its own isolated pip version.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 08:11:06