Issue
When finding an interesting Python Jupyter Notebook, such as 02.00-Introduction-to-NumPy.ipynb, I usally have to:
- download it locally
- open a shell in the same folder (tip: use SHIFT+RIGHT CLICK+ Open command window here to save 30 second browsing in the different folders) and do
jupyter notebook
- select the right .ipynb file, and finally run the code
Isn't there an easier way to do this?
What is the natural way to open a .ipynb notebook which is online, and run the code, without having to manually download the .ipynb?
Note: the notebook is visible here: https://github.com/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/02.00-Introduction-to-NumPy.ipynb but we can't run the code
Solution
@jakevdp builds in a nice way to do that, see here. In short, on each page he has an Open in Google Colab
button:
@GoogleColab can open any @ProjectJupyter notebook directly from @github!
To run the notebook, just replace "http://github.com " with "http://colab.research.google.com/github/ " in the notebook URL, and it will be loaded into Colab.
Example: 02.00-Introduction-to-NumPy.ipynb becomes: https://colab.research.google.com/github/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/02.00-Introduction-to-NumPy.ipynb
By default, code will run on Colab's distant server, but it's also possible to run it locally, by clicking on top right's Connect to local runtime...
:
I personally prefer the MyBinder project as a route. It will open temporary, active sessions with the contents of any Github repo, Github Gists, Gitlab repo, Zenodo archive, Dataverse repo, Datashare archive, Figshare archive, and others. Many repositories already include the necessary configuration files and even put a launch binder
button them. Some don't but you can go to the form at MyBinder project and generate a session. That form will also generate a URL that you can use to target the public MyBinder system to open a session alter For example, this person posted the link to open a session for all of Jakes notebooks, you just got to the URL https://mybinder.org/v2/gh/jakevdp/PythonDataScienceHandbook/master?filepath=notebooks%2FIndex.ipynb to tell MyBinder to start a session. Then from the index page that comes up you can click on the link you listed above and run it. Jake included configuration files that MyBinder also recognizes. Note, for some repositories or archives you'll point MyBinder at, it won't have the necessary configuration files and so you can run %pip install <package_name_here>
or %conda install <package_name_here>
in the current session and continue on running code. Limitations include that you have to be concerned with not sharing anything you wouldn't mind be public, limited resources, and FTP is not allowed to avoid abuse.
Some others to get you started:
A Gallery of Popular Binders (You'll note the one you referenced is listed in the number one position under
Featured Projects
there.)Sample Binder Repositories For example, the first one listed there includes the library seaborn installed in the environment that launches & uses it to plot a figure.
Answered By - Wayne
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.