Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jobdiogenes/235620928c84e604c6e56211ccf681f0 to your computer and use it in GitHub Desktop.
Save jobdiogenes/235620928c84e604c6e56211ccf681f0 to your computer and use it in GitHub Desktop.
Demo of use Google Drive/Sheets in R with Google Colaboratory.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nacnudus
Copy link

This stopped working, and can be fixed by doing the same for rlang as for httr.

# Check if is running in Colab and redefine is_interactive()
if (file.exists("/usr/local/lib/python3.6/dist-packages/google/colab/_ipython.py")) {
  install.packages("R.utils")
  library(R.utils)
  library(httr)
  library(rlang)
  my_check <- function() {return(TRUE)}
  reassignInPackage("is_interactive", pkgName = "httr", my_check) 
  reassignInPackage("is_interactive", pkgName = "rlang", my_check) 
}

@jobdiogenes
Copy link
Author

@nacnudus Thanks for your reply.

I saw that stop working some days ago, then
I add options(rlang_interactive=TRUE), which solve too, but I forgot to push the correction to gist.
They have change httr code in some way that now need more hacks. :(

@ClaudiuPapasteri
Copy link

@jobdiogenes Have been using your solution for some time. Thank you for it. I hate to say it but it's broken again.

@jobdiogenes
Copy link
Author

@ClaudiuPapasteri, this stop working because Google update to python 3.7. I just update. And now are working again.
If you perhaps use the code only online in Colab, you could remove if (file.exists( .... ))

Thanks to report

@gsekn
Copy link

gsekn commented Mar 15, 2021

seems to work in online colab if you just change 3.6 to 3.7
if (file.exists("/usr/local/lib/python3.7/dist-packages/google/colab/_ipython.py")) {

but someone with greater skill should confirm.

@monitarb
Copy link

In my case neither /usr/local/lib/python3.6/dist-packages/google nor /usr/local/lib/python3.7/dist-packages/google folder existed.
However running the original code without if (file.exists(....)) worked for me!

@jobdiogenes
Copy link
Author

jobdiogenes commented Apr 13, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment