Mahmoud Sallam
Mahmoud Sallam

Reputation: 61

Google Colab (Python, jupyter notebook) terminal input

I am running .py script with arguments, but the code asks for input and I can not enter anything as seen in the picture. enter image description here

Upvotes: 6

Views: 10182

Answers (2)

Bob Smith
Bob Smith

Reputation: 38694

Updated: Colab now supports input prompts. Try running things again, and you should see a prompt like so:

enter image description here

Upvotes: 3

Bal Krishna Jha
Bal Krishna Jha

Reputation: 7286

If you know beforehand what inputs you want to enter then you can use:

! printf 'y\ny\ny\n' | python run.py --task 1 --gpu -1 --data "data/"

In above case, if terminal prompts for an input three times, it will enter first y then y then y. \n is just for newline.

e.g-

If you need to enter only two input, say q followed by d then it should look like:

! printf 'q\nd\n' | python run.py --task 1 --gpu -1 --data "data/"

Upvotes: 1

Related Questions