How to import a library that is not in Google Colab?

Posted 1 week, 6 days ago

Google Colab lets us perform resource-intensive tasks with the best performance. Sometimes our code requires us to call some third-party libraries that are not available by default in Colab. In such a situation developer needs not be stuck.

He can just go and install them with appropriate calls.

In this article, we'll discuss a way to get those third-party library assets in our notebook.

Just substitute pip install <package> with !.

e.g. Suppose you want to install a package, "torch-dreams", you can run this command:

!pip install torch-dreams

You can also install modules that require, apt-get packages, like,

!apt-get -qq install -y libarchive-dev && pip install -U libarchive

It is a Python adapter for universal, libarchive-based archive access.