Reputation: 7451
I am trying to get some open source software working. It uses things that I don't have on my system (pytorch for example) and so I thought that I could try to run it on Google Colab.
When I tried to do it though, there are some python scripts that I have to run after cloning a directory from a github repository. I guess I can't run another python script from inside a Jupyter Notebook, and so I suppose that I'm trying to do something with Colab that it isn't designed to do?
Is there something available that is more like a terminal, but using the software, GPUs etc. that are available on Colab?
Upvotes: 4
Views: 8943
Reputation: 1617
As Wayne mentions in the comment korakot's answer, you can use the magic command
%run 'script.py'
This also allows you to do e.g. run in the notebook's namespace by using the -i
parameter
%run -i 'script.py'
Upvotes: 1
Reputation: 24681
You can run any shell command from jupyter-like environment (which includes colab
) using !
in code cell, for example
!ls
Would list all files in colab's cwd
.
To run python
script you could do:
!python script.py
It works just like terminal (it might be python3
, not sure how it's setup un colab
)
Upvotes: 5
Reputation: 40773
You can call your script too.
!python script.py
But you need to put the script there, probably by git clone
or direct uploading.
Upvotes: 3