繁体   English   中英

pip 安装了 google.colab,现在无法在 Jupyter 笔记本上运行代码

[英]pip installed google.colab and now unable to run code on Jupyter notebook

我使用pip install google.colab ,在我的终端中安装了 google.colab,之后我正在使用的 jupyter 笔记本停止工作。 当我打开一个新的 jupyter notebook 时,我无法运行任何代码。 当我尝试运行任何代码时,它一直停留在In[*]上。 在安装 google.colab 之前,我的笔记本工作正常。 我尝试重新启动我的 kernel 但这不起作用。 我还使用pip uninstall google.colab但它给出了以下内容: WARNING: Skipping google.colab as it is not installed. 然后我尝试通过pip uninstall google-colab卸载它,它成功卸载它,但没有解决问题。

我不确定 google.colab 是否是无法在 jupyter notebook 上运行代码的原因,但这在安装后立即发生。

我有以下软件包,包括 jupyter 的版本

jupyter                            1.0.0    
jupyter-client                     5.3.3    
jupyter-console                    6.0.0    
jupyter-core                       4.5.0    
jupyterlab                         1.1.4    
jupyterlab-server                  1.0.6 

谁能帮我? 谢谢

如果您已经卸载了collab,那么现在您必须将 go 到 anaconda 提示 shell。 输入命令:

pip list --outdated

它将显示您 PC 上所有已过时的软件包。 Then close anaconda prompt shell and now go to windows powershell.( You can just search in the searchbox of taskbar. Run the windwos powershell and type this command:

pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}

这将需要一段时间,您可能会看到一些红色,但在所有升级完成之后。 退出 powershell 并重新启动 anaconda 看看是否可行。

我刚刚遇到了完全相同的问题,这就是我为解决它所做的。

这是因为当您安装 google.colab 时,它需要大量的软件包,其版本比当前常用的版本要旧得多。 因此,如果您已经安装了这些软件包的较新版本(并且依赖于 jupyter),pip 实际上将卸载您的较新版本并安装 google.colab 所需的旧版本。 这种不良行为会导致 jupyter 失败。

pip install google.colab
...
ERROR: tensorboard 2.2.2 has requirement google-auth<2,>=1.6.3, but you'll have google-auth 1.4.2 which is incompatible.
Installing collected packages: portpicker, pandas, six, google-auth, tornado, simplegeneric, prompt-toolkit, ipython, ipykernel, idna, requests, notebook, google.colab
  Attempting uninstall: pandas
    Found existing installation: pandas 1.0.4
    Uninstalling pandas-1.0.4:
      Successfully uninstalled pandas-1.0.4
  Attempting uninstall: six
    Found existing installation: six 1.15.0
    Uninstalling six-1.15.0:
      Successfully uninstalled six-1.15.0
  Attempting uninstall: google-auth
    Found existing installation: google-auth 1.18.0
    Uninstalling google-auth-1.18.0:
      Successfully uninstalled google-auth-1.18.0
  Attempting uninstall: tornado
    Found existing installation: tornado 6.0.4
    Uninstalling tornado-6.0.4:
      Successfully uninstalled tornado-6.0.4
  Attempting uninstall: prompt-toolkit
    Found existing installation: prompt-toolkit 3.0.5
    Uninstalling prompt-toolkit-3.0.5:
      Successfully uninstalled prompt-toolkit-3.0.5
  Attempting uninstall: ipython
    Found existing installation: ipython 7.15.0
    Uninstalling ipython-7.15.0:
      Successfully uninstalled ipython-7.15.0
  Attempting uninstall: ipykernel
    Found existing installation: ipykernel 5.3.0
    Uninstalling ipykernel-5.3.0:
      Successfully uninstalled ipykernel-5.3.0
  Attempting uninstall: idna
    Found existing installation: idna 2.9
    Uninstalling idna-2.9:
      Successfully uninstalled idna-2.9
  Attempting uninstall: requests
    Found existing installation: requests 2.23.0
    Uninstalling requests-2.23.0:
      Successfully uninstalled requests-2.23.0
  Attempting uninstall: notebook
    Found existing installation: notebook 6.0.3
    Uninstalling notebook-6.0.3:
      Successfully uninstalled notebook-6.0.3    
Successfully installed google-auth-1.4.2 google.colab idna-2.8 ipykernel-4.6.1 ipython-5.5.0 notebook-5.2.2 pandas-0.24.2 portpicker-1.2.0 prompt-toolkit-1.0.18 requests-2.21.0 simplegeneric-0.8.1 six-1.12.0 tornado-4.5.3

当您卸载 google.colab 时,那些旧版本的软件包仍然存在。 所以解决方案是在安装 google.colab 之前将这些包更新到它们的版本。

只需检查您的龙卷风或某些基本库的过时版本。 在我的情况下,这些就像龙卷风,提示工具包

从终端启动笔记本只需在笔记本再次冻结时检查您的终端现在不要关闭任何东西只需 go 到您打开笔记本的终端检查哪个线程导致问题或库安装或更新该库。

这肯定会有所帮助。 它也适用于我

这很简单:

  1. Go 到 Jupyter 中的环境。
  2. 查看笔记本在哪个环境中不起作用/不是 output。
  3. 在不工作的环境 select 环境中。
  4. 删除环境。
  5. 直接添加你想要的Python版本重新安装需要的环境; 大约需要5-10分钟。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM