Python 用于安装熊猫的Sagemaker生命周期配置不工作

Python 用于安装熊猫的Sagemaker生命周期配置不工作,python,pandas,amazon-web-services,pip,amazon-sagemaker,Python,Pandas,Amazon Web Services,Pip,Amazon Sagemaker,我正在尝试在生命周期配置中更新pandas,下面是AWS示例,我有下一个代码: #!/bin/bash set -e # OVERVIEW # This script installs a single pip package in a single SageMaker conda environments. sudo -u ec2-user -i <<EOF # PARAMETERS PACKAGE=pandas ENVIRONMENT=python3 source /hom

我正在尝试在生命周期配置中更新pandas,下面是AWS示例,我有下一个代码:

#!/bin/bash

set -e

# OVERVIEW
# This script installs a single pip package in a single SageMaker conda environments.

sudo -u ec2-user -i <<EOF
# PARAMETERS
PACKAGE=pandas
ENVIRONMENT=python3
source /home/ec2-user/anaconda3/bin/activate "$ENVIRONMENT"
pip install --upgrade "$PACKAGE"==0.25.3
source /home/ec2-user/anaconda3/bin/deactivate
EOF
所以我们可以看到我确实在python3env中,尽管版本是0.24

但是,登录cloudwatch显示它已安装:

Collecting pandas==0.25.3 Downloading https://files.pythonhosted.org/packages/52/3f/f6a428599e0d4497e1595030965b5ba455fd8ade6e977e3c819973c4b41d/pandas-0.25.3-cp36-cp36m-manylinux1_x86_64.whl (10.4MB)
2020-02-03T12:33:09.065+01:00
Requirement already satisfied, skipping upgrade: pytz>=2017.2 in ./anaconda3/lib/python3.6/site-packages (from pandas==0.25.3) (2018.4)
2020-02-03T12:33:09.065+01:00
Requirement already satisfied, skipping upgrade: python-dateutil>=2.6.1 in ./anaconda3/lib/python3.6/site-packages (from pandas==0.25.3) (2.7.3)
2020-02-03T12:33:09.065+01:00
Requirement already satisfied, skipping upgrade: numpy>=1.13.3 in ./anaconda3/lib/python3.6/site-packages (from pandas==0.25.3) (1.16.4)
2020-02-03T12:33:09.065+01:00
Requirement already satisfied, skipping upgrade: six>=1.5 in ./anaconda3/lib/python3.6/site-packages (from python-dateutil>=2.6.1->pandas==0.25.3) (1.13.0)
2020-02-03T12:33:09.065+01:00
Installing collected packages: pandas Found existing installation: pandas 0.24.2 Uninstalling pandas-0.24.2: Successfully uninstalled pandas-0.24.2
2020-02-03T12:33:12.066+01:00
Successfully installed pandas-0.25.3

有什么问题吗

如果只想在中为python3环境安装软件包,请在创建Sagemaker生命周期配置中使用以下脚本

#!/bin/bash
sudo -u ec2-user -i <<'EOF'

# This will affect only the Jupyter kernel called "conda_python3".
source activate python3

# Replace myPackage with the name of the package you want to install.
pip install pandas==0.25.3
# You can also perform "conda install" here as well.
source deactivate
EOF
#/bin/bash

sudo-u ec2 user-i当Lifecycle Cloudwatch表示已成功安装特定内核时,笔记本电脑中没有软件包时,我遇到了完全相同的问题。我的解决方案是确保在打开笔记本电脑之前完成安装

#!/bin/bash
sudo -u ec2-user -i <<'EOF'

# This will affect only the Jupyter kernel called "conda_python3".
source activate python3

# Replace myPackage with the name of the package you want to install.
pip install pandas==0.25.3
# You can also perform "conda install" here as well.
source deactivate
EOF