Coursera jupyterNotebook: revert to the beginning - python

I'm using jupyterNotebook from Coursera but see no way to revert everything to the beginning.
The only option relevant seems to be "Revert to Checkpoint" -- but I didn't save a checkpoint at the beginning.
Does it mean that I am unable to revert to it?

Open your notebook at Coursera
Rename it
After renaming just add ?forceRefresh=true to the end of your notebook URL
Hit enter
You now have old renamed version and new refreshed to default one

The procedure is described here.
As of July 2019 the ?forceRefresh=true solution worked for me.

These steps will work as of April, 2020:
Rename your notebook and add ?forceRefresh=true to the url and press enter. Your entire Jupyter notebook will be restarted. Go to the course week and a fresh notebook will be there.

Better late than never -
This is from the Coursera help section.
To keep your old work and also get a fresh copy of the initial Jupyter Notebook:
Make a copy of your Notebook by clicking File, then Make a copy. We recommend using a naming convention such as “Assignment 1 - Initial” and “Assignment 1 - Copy” to keep your notebook environment organized. You can also download this file locally.
Click Control Panel, then choose My Server
Find the name of your previous file, as well as the new copy of your file.
Delete the original notebook file (not the copy) by selecting the checkbox next to the filename. Click the trashcan icon that appears to delete the file.
Click Control Panel, then choose Stop My Server.
Select My Server to restart.
After a few minutes, launch the notebook again from your Course Home. If you get a 404 error while the notebook server restarts, wait a few minutes and try again.
After the restart is complete, you will see a fresh copy.
I believe this is a new feature in Coursera

This is the instruction from a course I was taking:
In any Jupyter notebook, first save your work by going clicking File -> Download as -> Notebook (.ipynb)
Next, click File -> Open. This opens up the file directory.
Select the notebook you wish to refresh from the list by clicking the check box next the the filename
Click the trashcan icon at the top to delete the notebook
Copy this text: ?forceRefresh=true and paste it onto the end of the URL in your browser bar then hit .
You will see your workspace refresh with the updated copy of the notebook

These steps:
1. Open your notebook at Coursera
2. Rename it
3. After renaming just add `?forceRefresh=true` to the end of your notebook URL
4. Hit enter
5. You now have old renamed version and new refreshed to default one
Still work as of 05/14/2021

Related

Trusting a notebook is not working in PyCharm

I want to run a Jupyter notebook in PyCharm but on cells that are executing javascript, I get the message, that the notebook is not trusted.
When I click the "Trusted" checkbox, the arrow appears for a second and then disappears again. The notebook stays untrusted. Also using the command-line interface for Jupyter with
jupyter trust notebook.ipynb
doesn't work.
When I open the notebook on the browser with the same kernel running, it works just fine.
I also want to add that I have three projects open at the same time. When I just open the project, which is containing the notebook, I can click the "Trusted" checkbox and it will stay checked, but still, the javascript cells will not execute.
Maybe that's a bug, but probably I messed up some settings? Can you help me find out, which settings I can change and if there are other options to get the notebook trusted within the IDE?
Have a nice day!
I had the same problem when I moved the notebook's directory. What solved it for me in PyCharm was to copy and paste the notebook's content into a new file.
I came across this issue when specifying %matplotlib notebook.
Changing this to %matplotlib inline got the plotting to work.
Not fully understanding the issue or how this solves it but it is sufficient for my application.

In Jupyter notebook, how does one revert/refresh to the original notebook before any changes were made?

I'm forced to use jupyter notebook for a class. Somehow a code block got turned into text and now it won't run this cell. I want to revert the notebook to the original (the notebook provided by course without my programs added in) before I made any changes to it. How does one do this?
The only thing I could find was this at jupyter refresh
Refresh your notebook
1. Rename your existing Jupyter Notebook within the individual notebook view
2. In the notebook view, add “?forceRefresh=true” to the end of your notebook URL
3. Reload the screen
4. You will be directed to your home Learner Workspace where you’ll see both old and new Notebook files.
5. Your Notebook lesson item will now launch to the fresh notebook.
But I'm unsure what the first two steps mean. I tried renaming and then adding “?forceRefresh=true” at the end, but that didn't help. Perhaps someone could advise? Thanks

Jupyter Notebook error. No such file or directory C:.../HOME

I have installed Anaconda2, and today decided to update to Anaconda3. I installed Anaconda3 at the same time as I uninstalled Anaconda2.
Now, Jupyter Notebook shows this error and quits every time I try to start it.
The path in the error message is: "C:\Users\Hongyi\Documents\%HOME%"
What is causing Jupyter Notebook to quit?
Okay it looks like I found a solution.
Jupyter started running after I created the appropriate folder in the appropriate path.
In my case, it is creating a folder named %HOME% (with percent signs), in the path shown in the error message.
Now Jupyter is up and running.
Thank you guys for your thoughts and suggestions.
After readed this solution I tried another one (a comfortable one for me):
Open the location of the "Jupyter Notebook" shortcut (right click > More > File location) and right click again > Properties. In the Destination field (Sorry if the label is another ... the thing is that my Windows is in Spanish and I don't remember how it's labeled this field in English) just change the %HOME% at the end for a path to your "Work Folder" (if you have not created one then just create it). And this way It works also.

Move .ipynb using the IPython Notebook Web Interface

After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?
As of Sep-21 2015, there is no direct feature that supports moving files. However, there is a simple workaround. (*)
Select the file that you want to move.
Click Rename
Add the new path to the beginning of the filename.
Click OK
That's it. You should be able to find your file in the new path.
(*) https://github.com/jupyter/notebook/issues/471
The steps below may be an overkill to explain how to move a Jupyter notebook file from one folder to another using Jupyter. . However, it may be useful for someone who may be trying this the first time.
Let's look at an example (with example screenshots) to move "practice.py.ipynb" from "/Learn/python/puzzles" folder to "/Learn/python/puzzles/exercises" folder.
Step 1: Check the status of "practice.py.ipynv" notebook
If status is "Running" then the option to "Move" the file will not show. Follow along to "Shutdown" the notebook.
If status does not show "Running" then proceed to Step 4.
Image link shows the status of the notebook. In our example it is "Running"
Step 2: Select the notebook by clicking the checkbox next to it.
Image link shows the options for the selected notebook. "Shutdown" is displayed as an option. Move is not an option for a running notebook
Step 3: Click the "Shutdown" button for the selected notebook to stop the "Running" notebook. Image link show the notebook is no longer running
Step 4: Select the notebook by clicking the checkbox next to it. Image link shows the options for the selected notebook. "Move" is displayed as an option
Step 5: Click "Move" button. A pop-up window is displayed with the current path (folder) of the notebook. Image link shows current path as "/Learn/python/puzzles"
Step 6: Specify the folder where you want to move the notebook. Then click the "Move" button on the pop-up window. Image link shows here in our example, we would like to move it to "/Learn/python/puzzles/exercises" folder
File is no longer displayed in the current folder "/Learn/python/puzzles". File is no longer in the current folder. Image link shows practice.ipynb file is not in "/Learn/python/puzzles" folder anymore
Step 7: Click the exercises folder to navigate to "/Learn/python/puzzles/exercises" folder.
Image link shows notebook "practice.ipynb" is moved to "/Learn/python/puzzles/exercises" folder
If some stumbles here as of 2020, it's now possible to move .ipynb or other kind of files by simply checking it and clicking move.
Nevertheless, for .ipynb files you must be sure that the notebook isn't running (gray icon). If it's running it should be green and you must shut it down before moving.
It's kind of a workaround, but you can do this:
Navigate to the directory you want to put the file in
Click the Click Here
Find the file and upload
Ipython 5.1:
1. Make new folder -- with IPython running, New, Folder, select 'Untitled folder' just created, rename (and remember the name!)
2. Go to the file you want to move, Move, write new directory name at prompt
Note: If the folder exists, skip 1.
Note: If you want to leave a copy in the original directory, Duplicate and then move.
Ran into this issue and solved it by :
Create a new folder in jupyter notebooks.
Go to the folder/directory and click the "Upload "button which is next to the "New" button.
Once you click "Upload", your pc file explorer window will pop-up, now simply find where you have your jupyter notebooks saved on your local machine and upload them to that desired file/directory.
Although this doesn't technically move your python files to your desired directory, it does however make a copy in that directory. So next time you can be more organized and just click on a certain directory that you want and create/edit/view the files you chose to be in there instead of looking for them through your home directory.
Duplicate the notebook and delete the original, was my workaround.
JupyterLab (based on version 2.1.5), does not appear to have a direct move functionality (AFAICT), but does provide yet another workaround:
Right-click on the notebook file you want to move
Select "Cut"
Navigate to the destination folder to which you want to move it
Right-click in that folder (anywhere inside)
Select "Paste"
Note that the cut file doesn't immediately disappear from the original location when you cut it, but will be removed from its original location after pasting into the destination folder.

Links between IPython notebooks

Is it possible to link one IPython notebook to another with a hyperlink in a Markdown cell? If I try
Link to [Notebook 2](files/notebook2.ipynb)
or
Link to Notebook 2
A new tab is opened with raw unformatted contents of the ipynb file. Is there a way to get IPython to open another notebook for use in a new tab via a hyperlink?
Since IPython 2 you may use exactly the syntax you first tried:
Link to [Notebook 2](notebook2.ipynb)
It is now possible to do this with Ipython 1.0+ at least.
Just do:
localhost:8888/My Notebook.ipynb
Here is the documentation for this feature.
https://github.com/ipython/ipython/pull/3058
From http://python.6.n6.nabble.com/where-is-the-code-to-generate-IPython-Notebook-URL-for-a-new-ipynb-file-td4996991.html:
You can access a json version of all the notebooks from url: $host/notebooks
Here is a snippet that worked for me:
import urllib2
import json
data = urllib2.urlopen("http://127.0.0.1:8888/notebooks")
json_data=data.read()
list_o_dicts=json.loads(json_data)
for d in list_o_dicts:
if d['name'] == 'test':
print d['notebook_id']
Modify this according to your need.
** on further reading, I just realized OP was also seeking new notebook creation, keeping my answer anyway as way to work with linking existing notebooks.
One way to try for OP's goal is to run a script which will create a new notebook.ipynb file into the ipython folder where ipython notebook was started from. That .ipynb file can be templated from a new ipython notebook created from dashboard, with the name and id of the notebook replaced with whatever you are trying to link from your existing notebook. I have not tried this, but should work since dropping a .ipynb extension file into ipython folder does show it up in the dashboard.
Remember that if your file name has spaces you will need to replace those with %20
eg:
[Numpy](Numpy%20For%20Python.ipynb)
In addition to akim's suggestion - you can link to any (py or ipynb) file using a relative link, starting with "edit", and and then from the directory where you started the server.
E.g. in a markdown cell, if I want to reference a file whose relative location (relative to my git repo, which is also where I launched the notebook server) is "./path/to/source.py", I'd add:
[link to source](/edit/path/to/source.py)
Unfortunately, this is not practically possible.
The link would need to be to the notebook ID
(e.g. /a1e2a88f-3b91-4a4e-8ca1-d4fd7240f750 for the one I'm working on right now).
This is an UUID created at startup by the IPython server.
So you can copy the link from IPython Dashboard, but it will be valid only until you restart.

Categories