I want to create a project using python 3.8 but the default of google collab is the latest python (in this case version 3.11) how can I run the python 3.8 version on google collab? I have tried several tutorials but it still returns to python 3.11.
!apt-get --purge remove python3.11 !apt-get autoremove !apt-get clean
!apt-get update !apt-get install python3.8 !update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
!curl .py -o get-pip.py !python3.8 get-pip.py
import os os.kill(os.getpid(), 9)
I want to create a project using python 3.8 but the default of google collab is the latest python (in this case version 3.11) how can I run the python 3.8 version on google collab? I have tried several tutorials but it still returns to python 3.11.
!apt-get --purge remove python3.11 !apt-get autoremove !apt-get clean
!apt-get update !apt-get install python3.8 !update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
!curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py !python3.8 get-pip.py
import os os.kill(os.getpid(), 9)
Share Improve this question asked Feb 6 at 3:59 Riyan MahmudinRiyan Mahmudin 11 Answer
Reset to default 0To downgrade to Python 3.8 in Google Colab, you'll first need to install it by executing the shell command:
!sudo apt-get install python3.8
After installing Python 3.8, you need to set it as the default version using the commands:
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
Now you can verify that you've successfully downgraded your Python version by running:
!python --version
Finally, restart the Colab runtime to apply the changes. To do this, go to the "Runtime" menu and select "Restart runtime..."
You can also downgrade Python in Colab using Virtual Environments or Conda. See https://www.geeksforgeeks.org/how-to-downgrade-python-version-in-colab/ for more details on this.