pythonmodulegoogle-colaboratoryclipsys.path

Module not recognized with sys.path in colab


I'm running on Google Colab with files mounted on Google drive. I have set an absolute path that includes the file CLIP.

To call the subfile clip within, I use:

os.chdir(abs_root_path)
sys.path.append('./CLIP')
import clip

However, I get: ModuleNotFoundError: No module named 'clip' even though I can locate and see clip within CLIP in my drive: /content/drive/MyDrive/.../CLIP/clip


Solution

  • I had the same problem once. I solved it by uploading files directly into google colab.

    from google.colab import files
    
    uploaded = files.upload()
    

    Then you can browse your file and upload it.