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

Posted 8 months, 2 weeks 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. style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-4414117620201366"
data-ad-slot="7237412877">



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. style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-4414117620201366"
data-ad-slot="3299550751">



Just substitute pip install <package> with !.


e.g. Suppose you want to install a package, "torch-dreams", you can run this command: style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-4414117620201366"
data-ad-slot="3445469534">



!pip install torch-dreams


You can also install modules that require, apt-get packages, like, style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-4414117620201366"
data-ad-slot="3445469534">




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


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

style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-4414117620201366"
data-ad-slot="3445469534">