Upgrade version of python and pandas on Google Colab

Viewed 35

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. 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. Here is some code and output to make it clearer.

Python:

bash command

!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:

bash command

!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. 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.

1 Answers

Install the desired version of python and pandas as per your requirement on your google colab. Basically, google colab has debian-based linux, so what you do on linux you can do the same in google colab also.

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. So if you install the desired version in your google colab don't restart your runtime.

Related