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.

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

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

图片[1]-Need a different version of Python in SageMaker Studio Jupyter Notebooks? Here's how to create your own tile in the launcher! - 拾光赋-拾光赋
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!

原文链接:Need a different version of Python in SageMaker Studio Jupyter Notebooks? Here’s how to create your own tile in the launcher!

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容