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?

JohnB
질문됨 6달 전1944회 조회
1개 답변
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
전문가
답변함 6달 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠