In Google Colaboratory, I can install a new library using !pip install package-name
. But when I open the notebook again tomorrow, I need to re-install it every time.
Is there a way to install a library permanently? No need to spend time installing every time to use?
Yes. You can install the library in Google Drive. Then add the path to
sys.path
.Then you can install a library, for example,
jdc
, and specify the target.Later, when you run the notebook again, you can skip the
!pip install
line. You can justimport jdc
and use it. Here's an example notebook.https://colab.research.google.com/drive/1KpMDi9CjImudrzXsyTDAuRjtbahzIVjq
BTW, I really like
jdc
's%%add_to
. It makes working with a big class much easier.If you want a no-authorization solution. You can use mounting with gcsfuse + service-account key embedded in your notebook. Like this:
Then get your service account credential from google cloud console and embed it in the notebook
Then set environment to look for this credential file
You must then create (or have it already) a gcs bucket. And mount it to a made-up directory.
Then finally, install the library there. Like my above answer.
You can now
import jdc
without!pip install
it next time.