'Running python commands in a terminal in Google Colab

I've uploaded a directory of codes in Google Colabs. I need to run python command lines in a terminal that I'm unable to open.

I tried each and every solution suggested in How can I run shell (terminal) in Google Colab? but to no avail.

enter image description here



Solution 1:[1]

Updated 20220202

Can you try to execute your python scripts using the exclamation mark ! from Colab's cell directly?

I believe I encountered identical issue back in my Colab days, the process will hung or froze over some time, especially when I am dealing with GBs of datasets. So, ultimately I just ran using the exclamation mark directly from my Colab's cell to resolve the issue.

enter image description here


Have you tried this with the following syntax?

!pip install google-colab-shell
from google_colab_shell import getshell

getshell()
getshell(height=400)

I understood that you have tried the solution from another post, but just in case that you missed out the !, and ignored the warning message, and that exclamation mark was actually causing the shell not spawning.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1