I want to edit the .py file on Google Collaboration.

Asked 1 years ago, Updated 1 years ago, 121 views

As the title suggests, I would like to edit the .py file on Google Collaboration.

Specifically, I would like to edit the .py file that I installed with pip.
Could you edit it?

Or would it be possible to import the one I uploaded myself?

Thank you for your cooperation.

python google-colaboratory

2022-09-30 21:38

1 Answers

Wouldn't it be better to download the target file, edit it in the local environment, and then upload it on the side?

To be a little more specific, I'm going to use the package I installed on the Collaborative.

!pip show<package-name>

After confirming the installation location and checking the PATH of the target file,

 from google.colab import files
files.download (<PATH> for target files)


Download and edit to your local environment. After that,

files.upload()

Upload the edited file to the current directory and

!cp<Target Files><Target Files>PATH>Target Files

You can override it as .
If you want to use the edited file around, you may want to put it on Google Drive, mount it on the Collaboration, and copy it.

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

!cp"/content/drive/My Drive/target file"<PATH> for target files

It's easier to use your own package, simply upload it to the current directory (or copy from Google Drive) and import it.


2022-09-30 21:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.