Ubuntu 14.04升级aws-sam-cli至0.3.0失败问题求助
Hey there, let's break down why you're hitting that error and how to fix it quickly.
What's Causing the Error?
The root issues here are two-fold:
- Ubuntu 14.04 ships with Python 2.7 and an outdated version of
pipthat doesn't recognize modern package configuration options likepython_requires—which AWS SAM CLI 0.3.0 uses in its setup. - Even more importantly, AWS SAM CLI dropped support for Python 2.7 a while back. Your current Python 2.7 environment simply isn't compatible with SAM CLI 0.3.0 or newer versions.
Step-by-Step Fixes
1. Install Python 3.6+ (Ubuntu 14.04 Needs a Third-Party PPA)
Ubuntu 14.04's default Python 3 version is 3.4, which is too old for SAM CLI. We'll add a trusted PPA to get Python 3.6:
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.6 python3.6-dev
2. Set Up Pip for Python 3.6
Next, install and upgrade pip specifically for Python 3.6 (since the system pip is tied to Python 2.7):
curl https://bootstrap.pypa.io/pip/3.6/get-pip.py | sudo python3.6
3. Install/Upgrade SAM CLI with Python 3.6's Pip
Now use the updated Python 3.6 environment to install the SAM CLI version you want:
pip3.6 install --user --upgrade aws-sam-cli
4. Make the sam Command Accessible
Add the user-specific Python 3.6 bin directory to your system PATH so you can run sam from anywhere:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
5. Verify the Upgrade
Check that everything worked by running:
sam --version
You should see 0.3.0 (or a newer version if one's available) printed out.
Alternative: Use a Virtual Environment (If You Don't Want to System-Wide Upgrade)
If you prefer not to change your system's default Python setup, use a virtual environment to isolate the SAM CLI installation:
# Install virtualenv first sudo apt-get install virtualenv # Create a Python 3.6 virtual environment named sam-env virtualenv -p python3.6 sam-env # Activate the environment source sam-env/bin/activate # Install SAM CLI inside the environment pip install --upgrade aws-sam-cli # Check the version sam --version # When you're done, exit the environment with: # deactivate
内容的提问来源于stack exchange,提问作者amber gautam

