最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to change python version in Google Collab - Stack Overflow

programmeradmin3浏览0评论

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 1
Add a comment  | 

1 Answer 1

Reset to default 0

To 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.

发布评论

评论列表(0)

  1. 暂无评论