I tried running Ruby with Google Colab did not work as it is as of July 2020, so try it by trial and error with reference to Julia's example. I will introduce it because it went well.
Right-click this file and select "Save Link" on your computer. Download to.
Open https://colab.research.google.com/ and "upload" the file downloaded from the above ("File"-> "Upload notebook" if you opened Google Collaboratory for the first time).
A notebook with two pre-coded cells will open. Click the top cell and just press Shift + Enter (or the button with the right triangle) to execute. It will take some time.
At the bottom, runtime" ruby "is not recognized. I get the message
Connect to the default" python3 "but ignore it.
Go to the second cell, make an edit that leaves only the row for the gem you want to install, then press Shift + Enter (or the button with the right triangle) to do it.
Press Runtime> Change Runtime Type. This will bring up the Notebook Settings window with "ruby 2.5.1" selected as the "Runtime Type". Make sure "ruby 2.5.1" is selected as the "Runtime Type" and press "Save". (If it is not selected, select "ruby 2.5.1" from the list and save it.)
Now you have an environment to execute Ruby code.
For example, if you type RUBY_VERSION
and press Shift + Enter, you should see"2.5.1"
.
This is how to do the above manually. I will describe it in case the environment on the Google side changes.
Open https://colab.research.google.com/ and press "New Notebook" ("File"-> "New Notebook" if you opened Google Collaboratory for the first time) to create a new notebook. Create.
Download a blank notebook with nothing entered by selecting "File"-> "Download ipynb".
This section is done with a text editor on your computer.
Look for the following part of the file that starts with " kernelspec "
.
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
Rewrite the above " python 3 "
and " Python 3 "
for Ruby as follows.
"kernelspec": {
"name": "ruby",
"display_name": "ruby 2.5.1"
}
After rewriting, save it.
Upload the file you just rewritten from "File"-> "Upload Notebook" in Google Colaboratory on your web browser.
Copy and paste the following into the cell (where you enter) in Google Collaboratory.
!apt install libtool libffi-dev ruby-full make
!apt install libzmq3-dev libczmq-dev
!gem install ffi-rzmq
!gem install specific_install
!gem specific_install https://github.com/SciRuby/iruby
!iruby register
Then press Shift + Enter to run. It will take some time.
At the bottom, runtime" ruby "is not recognized. I get the message
Connect to the default" python3 "but ignore it.
Install additional gems as needed. Copy and paste the following, then leave only the line for the gem you want to install. Then press Shift + Enter to run.
!gem install awesome_print
!gem install pry
!gem specific_install https://github.com/SciRuby/daru
!gem specific_install https://github.com/SciRuby/daru-view
!gem install numo-narray
!gem install rumale
!gem install bio
Perform the same operation as "5. Switch runtime to ruby" in Easy Execution.
Now you have an environment to execute Ruby code.
I tried running Ruby on Google Colab --This article would not have been possible without this article. The apt installation package and iruby installation method have been partially changed based on this article.
Use Julia with Google Colab: Use the original notebook --How to rewrite json of ipynb and install the language after uploading and switch the runtime I referred to.
Recommended Posts