相关文章推荐
叛逆的沙发  ·  Convert data ...·  1 月前    · 
沉稳的木瓜  ·  Python_PyCharm_Turtle- ...·  1 月前    · 
叛逆的长颈鹿  ·  offset commit failed ...·  1 月前    · 
宽容的楼梯  ·  Python:Numpy ...·  1 年前    · 
没人理的豆芽  ·  linux grep命令 - 知乎·  1 年前    · 
贪玩的上铺  ·  ubuntu - Sub-process ...·  1 年前    · 

如何强迫google colab在特定的python版本中运行

0 人关注

I have a code which works in python3.5 but will throw errors in python>3.5 but with !python --version in google colab return python 3.6.9, is there any way I can force google colab to use 3.5. I found some solutions in Stackoverflow which asked me to use local run time which won't be useful for me because I don't have enough computational resources in my local machine.

python
python-3.x
google-colaboratory
Eswar Chitirala
Eswar Chitirala
发布于 2020-01-17
1 个回答
ngrislain
ngrislain
发布于 2022-03-17
0 人赞同

有一种方法可以使用你想要的任何版本的python,比方说python3.5,而不必在本地运行内核或通过ngrok代理。

下载colab笔记本。打开一个文本编辑器,将内核规格改为:。

"kernelspec": {
  "name": "py35",
  "display_name": "Python 3.5"

这和用在ǞǞǞ, 爪哇,以及高朗.

然后将编辑好的笔记本上传到Google Drive。在Google Colab中打开该笔记本。它找不到py35的内核,所以它使用普通的python3内核。 你需要安装一个Python 3.5的google-colab包和你上面定义的ipykernel的名字。"py35"。

!apt-get install python3.5
!curl -O https://bootstrap.pypa.io/pip/3.5/get-pip.py
!python3.5 get-pip.py
!python3.5 -m pip install jupyter google-colab
!python3.5 -m ipykernel install --name "py35" --user