How to upload and run python program in google colab?

Viewed 113

This may sound absurd but I want to write code using my preferred IDE and execute the written code in google collaborator.

I have a low-end PC and it takes ages to execute some codes (high-level codes) which takes much less time when running on Google Colab. So, is there a way to write code in local IDE, upload the code programmatically, and execute it (Output can be shown on the website/colab-site).

I can upload the program file to google drive programmatically but I need to manually execute it from colab which I want to avoid.

I want to write a code that can do all the above stuff like Upload the program to collab and execute it on the collab.

1 Answers

You can Upload your code to drive Then Mount

from google.colab import drive
drive.mount('/content/drive')

#Optional: move to the desired location:
%cd drive/My Drive/DIRECTORY_IN_YOUR_DRIVE

Install requirements(optional)

pip install REQUIREMENT

Then RUN your file using

python/python3 filename.py
Related