在Google Colaboratory中安装Python 3.8内核 [英] Install Python 3.8 kernel in Google Colaboratory

查看:739
本文介绍了在Google Colaboratory中安装Python 3.8内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用conda安装新的Python版本(3.8).

I try to install a new Python version (3.8) using conda.

!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

这很好.我可以打电话给!python script.py来运行3.8版本.

This works fine. I can call !python script.py to run a 3.8 version.

所以,我很幸运用Python 3.8内核安装了另一个jupyter内核.

So, I try my luck with installing another jupyter kernel with Python 3.8 kernel.

!conda install -q -y --prefix /usr/local jupyter
!python -m ipykernel install --name "py38" --user

我检查是否已安装内核.

I check that the kernel is installed.

!jupyter kernelspec list

然后我将笔记本电脑下载下来.打开文本编辑器,将内核规范更改为

Then I download the notebook down. Open a text editor to change the kernel specification to

"kernelspec": {
  "name": "py38",
  "display_name": "Python 3.8"
}

这与以前使用Javascript,Java和Golang的技巧相同.

This is the same trick that works before, with Javascript, Java, and Golang.

然后,我将编辑后的笔记本上载到Google云端硬盘.在Google Colab中打开笔记本.它找不到py38内核,因此它使用普通的python3内核.我再次运行所有这些单元格.

I then upload the edited notebook to Google Drive. Open the notebook in Google Colab. It cannot find the py38 kernel, so it use normal python3 kernel. I run all these cell again.

!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
!conda install -q -y --prefix /usr/local jupyter
!python -m ipykernel install --name "py38" --user

它像以前一样安装Python 3.8内核.我刷新了浏览器,以使其连接到新内核,希望它以前能够像JavaScript,Java和Golang内核一样工作.

It install the Python 3.8 kernel like before. I refresh the browser, to let it connect to the new kernel, hoping it to work like JavaScript, Java, Golang kernel before.

它不起作用.它无法连接.这是笔记本

It doesn't work. It cannot connect. Here's the notebook

任何帮助将不胜感激.

推荐答案

我发现了如何在Colab上运行Python 3.8笔记本.

I have found how to run Python 3.8 notebook on Colab.

  • 安装Anaconda3
  • 添加(伪造)google.colab库
  • 启动jupyterlab
  • 使用ngrok访问它

这是代码

# install Anaconda3
!wget -qO ac.sh https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh 
!bash ./ac.sh -b

# a fake google.colab library
!ln -s /usr/local/lib/python3.6/dist-packages/google \
       /root/anaconda3/lib/python3.8/site-packages/google

# start jupyterlab, which now has Python3 = 3.8
!nohup /root/anaconda3/bin/jupyter-lab --ip=0.0.0.0&

# access through ngrok, click the link
!pip install pyngrok -q
from pyngrok import ngrok
print(ngrok.connect(8888))

这篇关于在Google Colaboratory中安装Python 3.8内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆