Search code examples
pythongoogle-drive-apigoogle-colaboratory

How to run a script from a mounted Google drive. The issue is that the google drive folder has a space in its name


I mounted my drive using

from google.colab import drive
drive.mount('/content/drive')

I tried to run a script using

!python /content/drive/My Drive/script.py

But got this error

python3: can't open file '/content/drive/My': [Errno 2] No such file or directory

I think the issue is that the 'My Drive' folder has a space. Is there a workaround?


Solution

  • You need to add a backslash.

    !python /content/drive/My\ Drive/script.py