What you’re looking for is doable in the Web JupyterLab that Lambda sets up for you.
Here is a quick demonstration:
Step1: Setting up a normal instance, nothing special. 1x_A10 if curious, but not important for this demonstration:
Step2: Installing Python3.11 and setting up our VirtualEnv
After either SSH’ing in or using the Terminal
sessions from the JupyerLab:
# install Python 3.11 to our system
sudo apt update
sudo apt install python3.11 python3.11-venv
now let’s set up the Virtual Environment and activate it normally:
# make the venv
python3.11 -m venv mikesVenv
# activate
source mikesVenv/bin/activate
# check
which python
/home/ubuntu/mikesVenv/bin/python
-…obviously, name the virtualenv
whatever you’d like
Step3: Install ipykernel and add to Jupyter
Make sure your virtualenv is still activated from above and:
# install the ipykernel module
pip install ipykernel
# Add this environment to Jupyter
python -m ipykernel install --user --name=py311
Step4: Test it out!
Refresh your JupyterLab session for this instance and you should see your new py311
session ready and available to use if you go to File
→ New Launcher
:
-…and just replicating your test, making sure that we are indeed using our Python3.11 install:
And that’s all there is to it! Let me know if this solution works for you.
One last note/disclaimer: This is a fresh Python environment, so you won’t have things like Torch
and Tensorflow
which Lambda sets up for you out the box until you pip install them yourself in the venv.