Search code examples
pythonpipgoogle-colaboratoryinstapy

Location of the installed python packages using pip3 on Google colab


I am trying to build a instagram bot using instapy on google colab. I have installed the package using the following command in colab:

!pip3 install instapy

The issue is that I need to change some files in this module (ik its not recommended). But I cannot locate where in the google colab file system is this module installed.

I have tried looking into the "home" directory which is empty, as well as "/usr/lib/pythonx.x" of all the installed python versions but not there. Any help would be appreciated greatly. Thank you


Solution

  • Run the below code snippet in google colab for getting the directory where the packages are installed. Replace package in inspect.getfile(package) with the package you want to find the installation directory for. The package is located in /usr/local/lib/python3.7/dist-packages/instapy

    import os
    import inspect
    import instapy
    
    package_path = os.path.dirname(inspect.getfile(instapy))
    print(package_path)