def install_library_to_drive(libraries_list):
""" Install library on gdrive. Run this only once. """
drive_path_root = 'path/to/mounted/drive/directory/where/you/will/install/libraries'
for lib in libraries_list:
drive_path_lib = drive_path_root + lib
!pip install -q $lib --target=$drive_path_lib
sys.path.insert(0, drive_path_lib)
def load_library_from_drive(libraries_list):
""" Technically, it just appends install dir to a sys.path """
drive_path_root = 'path/to/mounted/drive/directory/where/you/will/install/libraries'
for lib in libraries_list:
drive_path_lib = drive_path_root + lib
sys.path.insert(0, drive_path_lib)
libraries_list = ["torch", "jsonlines", "transformers"] # list your libraries
install_library_to_drive(libraries_list) # Run this just once
load_library_from_drive(libraries_list)