Is there any way to upload my code in .py files and import them in colab code cells?
The other way I found is to create a local Jupyter notebook then upload it to Colab, is it the only way?
Is there any way to upload my code in .py files and import them in colab code cells?
The other way I found is to create a local Jupyter notebook then upload it to Colab, is it the only way?
You can upload those .py files to Google drive and allow Colab to use to them:
All your files and folders in root folder will be in
drive
.You can save it first, then import it.
Update (nov 18): Now you can upload easily by
%load filename.py
.Based on the answer by Korakot Chaovavanich, I created the function below to download all files needed within a Colab instance.
You can then use the usual 'import' statement to import your local files in Colab. I hope this helps
Try this way:
I have a package named plant_seedlings. The package is stored in google drive. What I should do is to copy this package in /usr/local/lib/python3.6/dist-packages/.