nbgrader returns a 404 in Preview tab due to bad url
In a standalone environment (no JupyterHub), for an assigned assignment, clicking on the preview tab returns a 404 (see attached Preview-404.jpg)
Notice the ......JupyterNotebookscoursesCSC343 after the tree node. This is the concatented directory path with the '/'s removed. tree = c:\Jupyter\Notebooks, CourseDirectory.root = c:\Jupyter\Notebooks\courses\CSC343
If I replace it in the url
with the correct path -> courses/CSC343, then I get the correct page!
same error and symptoms occur when I click on the assignment name on the formgrader to examine the files associated with that assignment. (same workaround works as well).
I am not sure if this a config file problem on my side or a bug?
I have also attached my config file, which is stored in the .jupyter directory (with the filetype chnaged due to githubs not accepting .py) nbgrader_config.txt .
Thanks rd
Hmm, this is very possibly a bug with the windows implementation. I'll investigate.
I'm unfortunately haven't trouble reproducing this. Are you still having this issue? If so, could you also paste the command line output that you get when you click the "generate" button?
Jess,
I generated the same assignment that has the other errors ( I generated it a couple of days earlier as well, that is why the removing message in the log).
Attached is a text file with both the generate popup log message and jupyter server terminal window output. Generate-Ouput-8-13-2017.txt
Thanks
rd
Can you tell me what versions you have of the following:
- Windows
- Python
- Jupyter notebook (you can get this with
jupyter notebook --versionon the command line)
Here is the info:
OS Name: Microsoft Windows 10 Home OS Version: 10.0.14393 N/A Build 14393 Python 3.5.2 :: Anaconda 4.2.0 (64-bit) jupyter notebook --version 4.2.3
I can't test this right now unfortunately, but potentially this could be an issue with the version of the jupyter notebook? Could you try upgrading it to the latest version?
I completed these tasks:
- saved my jupyter and nbgrader config files,
- uninstalled Anaconda,
- installed latest Anaconda
- reinstalled nbgrader
- moved config files to .jupyter
- Output from version commands:
Python 3.6.1 :: Anaconda 4.4.0 (64-bit) C:>jupyter notebook --version 5.0.0
Unfortunately, formgrader exhibits the same behavior (404) on assignment preview and when you click on the assignment name.
rd
Hmm, I really am stumped unfortunately, and as I haven't been able to reproduce it that makes it very hard to debug 😞
Can you try starting with the simplest configuration of nbgrader possible (e.g. use nbgrader quickstart, with no configuration in ~/.jupyter) and see if the error still occurs? If it does not, can you try adding in pieces of your current configuration until the error occurs, and then paste here the two versions of the config (the one where the error occurs, and the one where it does not)?
Sounds like a logical plan. Will do. Will have something for you in the morning.
So here are my actions and results based on our plan. Let me know that this is what you wanted me to do:
- Here is the target command executed by the Jupyter Window Icon:
C:\Anaconda3\python.exe C:\Anaconda3\cwp.py C:\Anaconda3 "C:/Anaconda3/python.exe" "C:/Anaconda3/Scripts/jupyter-notebook-script.py" %USERPROFILE%
The %USERPROFILE% sets the starting directory as C:\users\Roland_2
-
In a terminal, I moved to C:\users\Roland_2 and executed 'nbgrader quickstart CSC490' I received all the usual successful completion output
-
I changed the file type 'nbgrader.py -> nbgrader.xx' in .jupyter, logically deleting it.
-
I then started Jupyter notebook. As expected it pointed to C:\users\Roland_2.
-
I went into formgrader and it did not list any assignments (i.e. no ps1). My guess is without the nbgrader profile, it could not find the project I created.
-
I created a new assignment anyway thru the web interface. I discovered that it created it under C:\users\Roland_2\Documents\source\assignment
So after you created the assignment in the last step, did you find the error still occurred?
yup, when I click on the assignment name - the 404 comes back.
Can you try this, but try running the jupyter notebook from the command line (from the root of your course directory) rather than launching it via the icon?
I just did two tests - on both I ran from the directory created by quickstart for the course: Both produced the 404 result:
Test a - included the %USERPROFILE% parameter
C:\Users\Roland_2\CSC490>C:\Anaconda3\python.exe C:\Anaconda3\cwp.py C:\Anaconda3 "C:/Anaconda3/python.exe" "C:/Anaconda3/Scripts/jupyter-notebook-script.py" %USERPROFILE%
notebooks pointed to notebook directory C:\usrs\Roland_2, but nbgrader produced 404
Test b - did not include %USERPROFILE% parameter C:\Users\Roland_2\CSC490>C:\Anaconda3\python.exe C:\Anaconda3\cwp.py C:\Anaconda3 "C:/Anaconda3/python.exe" "C:/Anaconda3/Scripts/jupyter-notebook-script.py"
notebooks pointed to notebook directory in jupyter_profile.py, but nbgrader produced 404
I tried one other test.
From the command line pointing at the course directory, run 'jupyter notebook'
This does bring up the ps1 assignment in nbgrader !, but clicking on the assignment gives me the 404.
What browser are you using? Is it a problem in other browsers, too?
Also, is there any javascript console output on the formgrader page (before you click the link that takes you to the 404)? When you run the notebook from the command line, can you paste the log output here?
One thing I wanted to clarify to make sure it is not part of the problem. My tests today have been all through the web interface. Besides creating the course through quickstart, I have not completed anything else on the command line or through the db interface. There may not even be a database in existence for this new course. (Although all my previous days tests including creating students and assignments ahead of time on the db, and that is where I first received the 404s)
I have been using firefox. I changed my browser to Windows edge same error.
Here is the jscript console:

Here is the log from the server terminal:
C:\Users\Roland_2\CSC490>jupyter notebook [I 09:54:43.733 NotebookApp] Loading the formgrader nbgrader serverextension [I 09:54:43.764 NotebookApp] Loading the validate_assignment nbgrader serverextension [I 09:54:43.967 NotebookApp] Serving notebooks from local directory: C:\Jupyter\Notebooks [I 09:54:43.967 NotebookApp] 0 active kernels [I 09:54:43.967 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=3e34b3fd7b8f0d1a5bb58499157a9f456416c81cd05ec50a [I 09:54:43.967 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 09:54:43.983 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=3e34b3fd7b8f0d1a5bb58499157a9f456416c81cd05ec50a
[I 09:54:44.483 NotebookApp] Accepting one-time-token-authenticated connection from ::1 [W 10:02:31.904 NotebookApp] 404 GET /tree/source/ps1 (::1) 15.63ms referer=http://localhost:8888/formgrader
Thanks for the clarification. Just to clarify one other thing, the 404 is still due to the path being formatted without slashes, like ......JupyterNotebookscoursesCSC343, and is not just a regular 404?
The existence of the database shouldn't be a problem.
aaaaah, here is the url on the 404: http://localhost:8888/tree/source/ps1
so it may not be the slashes anymore?
The course directory is C:\users\Roland_2\CSC490 and the source/ps1 directory exists.
It is something overriding what /tree defaults to..... ?
I noticed I have this line commented out in my jupyter_config:
The default URL to redirect to from /
#c.NotebookApp.default_url = '/tree'
Can you paste the terminal output (from jupyter notebook) when you navigate to http://localhost:8888/tree/source/ps1 ?
This is what i did: I entered 'jupyter notebook' from the command line to bring up jupyter. In the url line I entered: http://localhost:8888/tree/source/ps1 I received a 404.
Here is the terminal output: C:\Users\Roland_2\CSC490>jupyter notebook [I 10:37:49.647 NotebookApp] Loading the formgrader nbgrader serverextension [I 10:37:49.678 NotebookApp] Loading the validate_assignment nbgrader serverextension [I 10:37:49.897 NotebookApp] Serving notebooks from local directory: C:\Jupyter\Notebooks [I 10:37:49.897 NotebookApp] 0 active kernels [I 10:37:49.897 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=802a37f7b4cd3aa307803a1a48ffa4c0119ddfdc9c87fbfb [I 10:37:49.897 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 10:37:49.897 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=802a37f7b4cd3aa307803a1a48ffa4c0119ddfdc9c87fbfb
[I 10:37:50.381 NotebookApp] Accepting one-time-token-authenticated connection from ::1 [W 10:38:00.529 NotebookApp] 404 GET /tree/source/ps1 (::1) 15.63ms referer=None
And the directory source/ps1 definitely exists? What files do you see when you look at the regular notebook list (not through the formgrader)? Can you navigate to source/ps1 there?
ok, think I am starting to see the pattern.
Pattern A:
Running from the command line via 'jupyter notebook' reports the 404. The url = http://localhost:8888/tree/source/ps1 The problem is tree = C:\users\Roland_2 The course folder = C:\users\Roland_2\CSC490 The assignment folder = C:\users\Roland_2\CSC490\source\ps1 The CSC490 folder is missing from the path. (when I add it to the url in formgrader, it finds it)
Pattern B:
When I run it from with the windows scripts: C:\Anaconda3\python.exe C:\Anaconda3\cwp.py C:\Anaconda3 "C:/Anaconda3/python.exe" "C:/Anaconda3/Scripts/jupyter-notebook-script.py" %USERPROFILE%
The url = http://localhost:8888/tree/..CSC490/source/ps1 like I mentioned prior.
In both cases, I get a 404, it is just the different ways of kicking it off is resulting in reporting the url differently, but still not found.
Ah, ok. For Pattern A, you need to run the notebook from the course directory itself (so "tree" should be the same as the course folder) or configure c.CourseDirectory.root. There was a bug with setting the config option, but it was fixed (see #855) and if you update nbgrader to 0.5.3 (released yesterday) it should be fixed.
For Pattern B, this sounds like it might be related to how anaconda runs the notebook. I'm not sure why that would happen, but I unfortunately can't investigate it further right now as I don't have access to a windows machine (I am in the process of moving to the UK, and my windows computer is currently on a ship making its way there...)
For the time being (once we verify you can get it working in the Pattern A case), I would suggest to use nbgrader that you always launch the notebook from the command line. Once I get my computer back (not until November probably, unfortunately, as the shipment takes 2-3 months 😞 ) I can try to investigate the Pattern B problem further, or maybe someone else who uses windows (like @lgpage ) could investigate if they have time.
Jess, I appreciate your effort today and over the last few weeks. Good luck with your move! I will do some more playing with it over the next couple of weeks. And will post my notes here. No need for you to rely with everything else you will be dealing with.
Thanks again and take care.
FYI - I changed the jupyter 'notebook directory' in the config to be the same as the course and it works fine. It has to do with building the path when the course directory is a subdirectory or different than the notebook directory. maybe I will try 5.3 to see if that fixes it.
No problem, I am glad we were able to make some headway on this at least 😄 Sorry that it's been so difficult to debug!
Definitely if you find anything interesting, leave notes about it here, and hopefully we can get it sorted out! Also, I forgot to mention, that I'll be traveling (starting on Monday) for the next six weeks and I won't be able to reply then. But if when I get back you've figured something out, we can hopefully get a fix in, or worst case when I get my windows machine back we can finish debugging then.
@rdpratti I would also recommend always starting Notebook (from the course directory itself) from the command prompt or by using this trick. In these example I recommend using jupyter-notebook (with a dash) instead of jupyter notebook (with a space) as I have found a difference in behaviour for different Windows versions when using jupyter notebook (with a space)
For pattern B you can change the default start location of Notebook by following either of the first two suggestions here
@jhamrick @rdpratti I was having the same issue here with missing slashes with my Windows installation of nbgrader and formgrader. If I manually add in the slashes I can get to the assignment files fine, but the link within formgrader is broken. Was there ever a fix for this? I couldn't find anything in this chain that addresses that.