简体   繁体   English

Google Colab上python和pandas的升级版

[英]Upgrade version of python and pandas on Google Colab

I need to use python 3.9.14 and pandas 1.4.2 on Google Colab because of the.npz files I need to work with.由于我需要使用.npz 文件,我需要在 Google Colab 上使用 python 3.9.14 和 pandas 1.4.2。 I have successfully installed both using bash commands on the notebook, but it is not effective on the actual version I can use on the notebook itself.我已经在笔记本上使用 bash 命令成功安装了两者,但在我可以在笔记本本身上使用的实际版本上无效。 Here is some code and output to make it clearer.这是一些代码和 output 使其更清晰。

Python: Python:

bash command bash 命令

!python --version
Python 3.9.14

notebook笔记本

import sys
print(sys.version)
3.7.14 (default, Sep  8 2022, 00:06:44) 
[GCC 7.5.0]

Pandas: Pandas:

bash command bash 命令

!pip list
    Package                 Version
----------------------- ---------------
...
pandas                  1.4.2
...

notebook笔记本

import pandas as pd
pd.__version__
1.3.5

Does anyone know how to fix the problem?有谁知道如何解决这个问题? It seems that I installed the right version on the virtual machine, but I can't use it on the Colab notebook.好像我在虚拟机上安装了正确的版本,但是在 Colab notebook 上无法使用。 I've tried restarting the runtime, but that leads to a loop: it continuously connects and disconnects to the runtime with no way to do anything.我已经尝试重新启动运行时,但这会导致一个循环:它不断地连接和断开运行时,没有办法做任何事情。 I hope you guys can help me.我希望你们能帮助我。 Thank you.谢谢你。

Install the desired version of python and pandas as per your requirement on your google colab.根据您对 google colab 的要求,安装所需版本的 python 和 pandas。 Basically, google colab has debian-based linux, so what you do on linux you can do the same in google colab also.基本上,google colab 有基于 debian 的 linux,所以你在 linux 上做的事情你也可以在 google colab 上做同样的事情。

Now as you say you restart runtime, basically you lost all your changes once you restart the kernel and google colab restore to its previous state, each runtime gives you a fresh and new google colab.现在,正如您所说的重新启动运行时,基本上,一旦您重新启动 kernel 并将 google colab 恢复到其以前的 state,您就会丢失所有更改,每个运行时都会为您提供全新的 google colab。 So if you install the desired version in your google colab don't restart your runtime.因此,如果您在 google colab 中安装所需的版本,请不要重新启动运行时。

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

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