简体   繁体   中英

How to upload and run python program in google colab?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM