DEV Community

Cover image for Need a different version of Python in SageMaker Studio Jupyter Notebooks? Here's how to create your own tile in the launcher!
Faye Ellis for AWS Community Builders

Posted on

2

Need a different version of Python in SageMaker Studio Jupyter Notebooks? Here's how to create your own tile in the launcher!

SageMaker Studio provides a cost effective and convenient way to access Jupyter Notebooks for running Python code, but what if you need a different version of Python, than the default one on offer?

Here's how to create your own bespoke virtual environment with everything you need to run your code.

1) In the SageMaker Studio Jupyter Lab, select terminal from the launcher.

Image description

2) In the terminal window, type this command which creates a new Python virtual environment, then downloads, extracts, and installs the specified version of Python that you need for your project.

conda create -n python_312 python=3.12.*
Enter fullscreen mode Exit fullscreen mode

Image description

3) Continuing in the terminal window, type the following command to activate the environment.

source activate python_312
Enter fullscreen mode Exit fullscreen mode

4) Next install the libraries needed for Jupyter notebooks (ipykernel and jupyterlab). At this point you can add any other libraries that you need in this environment. For my use case, I also needed matplotlib for creating visualizations, so I added that too!

python -m pip install ipykernel jupyterlab matplotlib
Enter fullscreen mode Exit fullscreen mode

5) Now we are ready to add our newly created Python environment to the Jupyter Lab launcher. I named it my_python_312_env.

python -m ipykernel install --user --name python_312 --display-name my_python_312_env
Enter fullscreen mode Exit fullscreen mode

Image description
After running this command, close the terminal session.

6) The new Python environment now appears in the SageMaker Studio Jupyter Lab launcher screen, select it, by selecting my_python_312_env!

Image description

Billboard image

Monitoring as code

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay