aws-samples / amazon-sagemaker-notebook-instance-lifecycle-config-samples

A collection of sample scripts to customize Amazon SageMaker Notebook Instances using Lifecycle Configurations
MIT No Attribution
422 stars 250 forks source link

Fixing search for boto3 python version #107

Closed tayodok closed 1 year ago

tayodok commented 1 year ago

Issue #, if available:

Description of changes:

Ami update in region breaks search for python version capable of boto3 import.

sh-4.2$ ls | grep python
python
python2
python2.7
python2.7-config
python2-config
python3
python3.7
python3.7m
python3.8
python3.8-config
python3.8-x86_64-config
python-config

sh-4.2$ /usr/bin/python3 --version
Python 3.7.16

sh-4.2$ /usr/bin/python3
Python 3.7.16 (default, Dec 15 2022, 23:24:54)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'boto3'
>>>

Testing Done

# Provide your commands here

sh-4.2$ if $(which python) -c "import boto3" 2>/dev/null; then
>     PYTHON_DIR=$(which python)
> elif /usr/bin/python -c "import boto3" 2>/dev/null; then
>     PYTHON_DIR='/usr/bin/python'
> else
>     # If no boto3 just quit because the script won't work
>     echo "No boto3 found in Python or Python3. Exiting..."
>     exit 1
> fi
sh-4.2$ echo $PYTHON_DIR
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python
sh-4.2$

sh-4.2$ /home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:53)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>>

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.