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

MacOS High Sierra下AWS CLI异常安装问题排查求助

Fixing Broken AWS CLI on macOS High Sierra

Let’s work through this stubborn AWS CLI issue—sounds like a leftover installation stuck in a broken state, messing with your SAM tooling and build scripts. Here’s how to track it down and get things working again:

Step 1: Locate the problematic aws executable

First, let’s pinpoint exactly where the broken aws command is stored. Run these terminal commands:

  • which aws – This should return the full path to the executable (e.g., /usr/local/bin/aws or ~/Library/Python/3.7/bin/aws)
  • If which aws returns nothing, reset your shell’s hash table first with hash -r, then try again.

If you still get no output, check your PATH with echo $PATH and look for any suspicious entries that might contain old AWS files.

Step 2: Identify the original installation method

Since you confirmed it wasn’t installed via Homebrew, narrow down the possible sources:

  • Pip/Pip3 installation: Run pip3 list | grep awscli (use pip if you might have used Python 2). If awscli shows up here, this was a Python-based install.
  • Official AWS PKG installer: Check if the directory /usr/local/aws exists—this is the default location for the official pkg install.
  • Manual binary download: Look for standalone aws binaries in common spots like /usr/local/bin, ~/bin, or custom directories you added to your PATH.

Step 3: Uninstall the broken installation

Use the method matching what you found in Step 2:

  • Pip/Pip3: Uninstall with pip3 uninstall awscli (or pip uninstall awscli for Python 2). Confirm the process completes successfully.
  • AWS PKG: Run the official uninstall script with sudo /usr/local/aws/bin/aws-uninstall. Enter your admin password when prompted.
  • Manual binary: Delete the executable file directly (e.g., rm /usr/local/bin/aws).

Step 4: Clean up residual files and PATH entries

To avoid leftover conflicts:

  • Back up your AWS configuration first if you want to keep credentials/settings: mv ~/.aws ~/.aws.bak
  • Open your shell configuration file (e.g., ~/.bash_profile for High Sierra’s default bash, or ~/.zshrc if you use zsh) and remove any lines adding old AWS-related paths to your PATH. Save the file and reload your shell with source ~/.bash_profile.

Step 5: Reinstall AWS CLI properly

For macOS High Sierra, the most reliable methods are:

  • Pip3 (user-level install, recommended):
    pip3 install awscli --upgrade --user
    
    This installs the CLI in your user directory, avoiding system permission issues. Ensure ~/Library/Python/3.7/bin (or your Python 3 version’s bin folder) is in your PATH.
  • Official AWS PKG Installer: Download the latest macOS pkg from AWS, run the installer, and it will automatically configure your PATH correctly.

Step 6: Verify the fix

Once reinstalled, test these commands to confirm everything works:

  • aws --version – Should return the current CLI version number
  • sam --version – Should now recognize the CLI and function normally
  • Run your build scripts to ensure they no longer hit AWS CLI-related errors

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 08:49:29