我尝试使用 conda 安装新的 Python 版本 (3.8)。
!wget -O mini.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh
!chmod +x mini.sh
!bash ./mini.sh -b -f -p /usr/local
Run Code Online (Sandbox Code Playgroud)
这工作正常。我可以打电话!python script.py来运行 3.8 版本。
因此,我尝试使用 Python 3.8 内核安装另一个 jupyter 内核。
!conda install -q -y --prefix /usr/local jupyter
!python -m ipykernel install --name "py38" --user
Run Code Online (Sandbox Code Playgroud)
我检查内核是否已安装。
!jupyter kernelspec list
Run Code Online (Sandbox Code Playgroud)
然后我把笔记本下载下来。打开文本编辑器将内核规范更改为
"kernelspec": {
"name": "py38",
"display_name": "Python 3.8"
}
Run Code Online (Sandbox Code Playgroud)
这与之前使用 Javascript、Java 和 Golang 的技巧相同。
然后我将编辑后的笔记本上传到 Google Drive。在 Google Colab 中打开笔记本。它找不到py38内核,所以它使用普通的python3内核。我再次运行所有这些单元格。
!wget -O mini.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh
!chmod +x mini.sh
!bash ./mini.sh -b -f …Run Code Online (Sandbox Code Playgroud)