How do I run a python script on a Sagemaker notebook instance?

0

I have a python script that I would like to run from a terminal attached to my sagemaker notebook instance. I'm using the provided Data Science 3.0 image on a t3.medium.

My process:

  1. Start the notebook instance
  2. Launch terminal using icon in notebook toolbar
  3. Activate conda environment (base)
  4. Run script with: python myscript.py arg1

At this point I receive this error: ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /opt/conda/lib/python3.10/site-packages/pandas/_libs/window/aggregations.cpython-310-x86_64-linux-gnu.so)

The above error stems from a simple import sagemaker statement

The import runs perfectly fine in the notebook, however in the terminal I get the error. From what I can tell the kernel and system path are both identical. Running !python myscript.py arg1 from inside the notebook also returns the same error. What am I missing?

1 Risposta
0

Hi - Thanks for reaching out. In the notebook can you please run !which python and !echo $PATH to determine the Python interpreter and path being used. Can you please also do the same in the terminal and compare the outputs?

profile pictureAWS
ESPERTO
con risposta 6 mesi fa
  • Hi! So the kernels are the same, however the paths are in fact different. The notebook has the following paths that the terminal is missing: /opt/amazon/bin:/tmp/miniconda3/condabin:/tmp/anaconda3/condabin:/tmp/miniconda2/condabin:/tmp/anaconda2/condabin:/tmp/mambaforge/condabin I tried appending the above paths to the terminal system path, however I receive the same error. In fact, the above directories do not seem to exist within the terminal.

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande