hide_code icon indicating copy to clipboard operation
hide_code copied to clipboard

500: Internal Server Error when exporting to... anything?

Open towight opened this issue 4 years ago • 6 comments

Hi kirbs Thanks for providing the hide_cell extension. I am a complete newb to SageMath, though I have some experience (completely irrelevant in this case) with Mathematica. I am running SageMath 9.2 in a Jupyter notebook under Windows 10 and have installed hide_code as, without it, I find Sage to be a great package, doing what it does very well indeed, but of very little value to me without the ability to produce output free of code.

After some trouble with hide_code not operating properly I found success last night, at least with correct output of PDF via LaTex, so I felt pretty good. Today it has been completely non-functional again. I have tried re-installs to no avail, consistently getting 500: Internal Server Errors whichever export I try.

I note that I have also been using sethome to change my home directory and there does seem to be some interaction between this and hide_code. Hide_code was installed while my home directory was other than the Sage/Jupyter default. I find that when I launch Sage in this configuration hide_code is listed as being enabled in the Jupyter console, but it appears that, when attempting to export using hide_code it attempts to find the file in the default Home directory (users/username/etc). If I then use sethome to change my home directory to the default it appears from the console output that hide_code is no longer enabled.

I did try re-installing hide_code with the default home directory selected and it appeared to be enabled but it was still non-functional re: exporting though, as has always been the case, it does hide code etc. in the notebook view. Here is the console output from an attempted export to PDF via LaTex.

`┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 9.2, Release Date: 2020-10-24 │ │ Using Python 3.7.7. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ Please wait while the Sage Jupyter Notebook server starts... [I 16:19:38.669 NotebookApp] Using MathJax: nbextensions/mathjax/MathJax.js [I 16:19:39.628 NotebookApp] hide_code: Attempting to load hid_code export handler extensions. [I 16:19:39.631 NotebookApp] hide_code: Hide_code export handler extensions loaded. [I 16:19:39.632 NotebookApp] Serving notebooks from local directory: /home/sage [I 16:19:39.632 NotebookApp] Jupyter Notebook 6.1.1 is running at: [I 16:19:39.632 NotebookApp] http://localhost:8888/?token=33f4688b83f59f7e04e5e0973fc98a55a0b8f6cb02150b18 [I 16:19:39.632 NotebookApp] or http://127.0.0.1:8888/?token=33f4688b83f59f7e04e5e0973fc98a55a0b8f6cb02150b18 [I 16:19:39.633 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 16:19:39.654 NotebookApp]

To access the notebook, open this file in a browser:
    file:///home/sage/.local/share/jupyter/runtime/nbserver-381-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/?token=33f4688b83f59f7e04e5e0973fc98a55a0b8f6cb02150b18
 or http://127.0.0.1:8888/?token=33f4688b83f59f7e04e5e0973fc98a55a0b8f6cb02150b18

[I 16:19:50.099 NotebookApp] Kernel started: c78345d3-111d-47e3-9d56-b00260de87db, name: sagemath [I 16:20:22.573 NotebookApp] Saving file at /sage/New File.ipynb [I 16:20:37.254 NotebookApp] Starting buffering for c78345d3-111d-47e3-9d56-b00260de87db:bb856379c90d428f88f85324f804373f [I 16:20:37.258 NotebookApp] hide_code: Starting Latex PDF export for /New File.ipynb [E 16:20:37.260 NotebookApp] Uncaught exception GET /notebooks/New%20File.ipynb/sage/New%20File.ipynb/export/latexpdf (127.0.0.1) HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/New%20File.ipynb/sage/New%20File.ipynb/export/latexpdf', version='HTTP/1.1', remote_ip='127.0.0.1') Traceback (most recent call last): File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/tornado/web.py", line 1701, in _execute result = method(self.path_args, **self.path_kwargs) File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/hide_code/hide_code.py", line 58, in get with open(ipynb_file_name(args), encoding="utf-8") as f: FileNotFoundError: [Errno 2] No such file or directory: '/home/sage/New File.ipynb/sage/New File.ipynb' [E 16:20:37.267 NotebookApp] { "Host": "localhost:8888", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Referer": "http://localhost:8888/notebooks/sage/New%20File.ipynb", "Cookie": "_xsrf=2|dd0b195e|6633b2d6953f663419dda408cee6e5b4|1608076637; username-localhost-8888="2|1:0|10:1608585581|23:username-localhost-8888|44:ZjBjZGI1MWM2ZDU1NGQzNDhmYmNhYzgxZTc1YmIzMWE=|64a0f92d43088c90ac6e950814df2334ae5e0d4880b60285ea46aaa5abea98a2"", "Upgrade-Insecure-Requests": "1" } [E 16:20:37.268 NotebookApp] 500 GET /notebooks/New%20File.ipynb/sage/New%20File.ipynb/export/latexpdf (127.0.0.1) 8.74ms referer=http://localhost:8888/notebooks/sage/New%20File.ipynb [I 16:20:37.274 NotebookApp] Restoring connection for c78345d3-111d-47e3-9d56-b00260de87db:bb856379c90d428f88f85324f804373f [I 16:20:37.281 NotebookApp] Starting buffering for c78345d3-111d-47e3-9d56-b00260de87db:bb856379c90d428f88f85324f804373f

` Any help you can provide would be very welcome, otherwise it's back to Mathematica :-(

towight avatar Dec 21 '20 21:12 towight

Update. Uninstalled hide_cell. Uninstalled Sage. Reinstalled Sage and hide_cell. Hide cell now exports PDF via Latex... almost. Everything works correctly in the notebook as far as I can tell. But in the PDF the plot I included did not show, as it should, whereas the prompt for that output cell does show, which it shouldn't.

towight avatar Dec 23 '20 02:12 towight

Can you post a sample notebook so l check it out? I'm not very familiar with Latex exporting. I might of missed a block display that's meant for plots/images.

kirbs- avatar Jan 04 '21 21:01 kirbs-

Well, there's nothing exotic about the notebooks I've been using to test this kirbs. But here is an example. This gives me a 500: Internal server error when using hide_code to export in any format, after hiding the code in the notebook and saving the notebook with the code hidden. I've attached the Notebook Server responses for the session.

pdf Test.zip

`┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 9.2, Release Date: 2020-10-24 │ │ Using Python 3.7.7. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ Please wait while the Sage Jupyter Notebook server starts... [I 13:06:01.737 NotebookApp] Using MathJax: nbextensions/mathjax/MathJax.js [I 13:06:02.681 NotebookApp] hide_code: Attempting to load hid_code export handler extensions. [I 13:06:02.684 NotebookApp] hide_code: Hide_code export handler extensions loaded. [I 13:06:02.686 NotebookApp] Serving notebooks from local directory: /home/sage [I 13:06:02.686 NotebookApp] Jupyter Notebook 6.1.1 is running at: [I 13:06:02.686 NotebookApp] http://localhost:8888/?token=98dd51882b907b2f166c541f525993b7140ef8cc13735562 [I 13:06:02.687 NotebookApp] or http://127.0.0.1:8888/?token=98dd51882b907b2f166c541f525993b7140ef8cc13735562 [I 13:06:02.687 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 13:06:02.706 NotebookApp]

To access the notebook, open this file in a browser:
    file:///home/sage/.local/share/jupyter/runtime/nbserver-1369-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/?token=98dd51882b907b2f166c541f525993b7140ef8cc13735562
 or http://127.0.0.1:8888/?token=98dd51882b907b2f166c541f525993b7140ef8cc13735562

[I 13:06:14.678 NotebookApp] Kernel started: 43385a78-dbf0-4fa6-b336-d136dfad9b32, name: sagemath [I 13:06:24.738 NotebookApp] Saving file at /pdf Test.ipynb [I 13:06:37.276 NotebookApp] Starting buffering for 43385a78-dbf0-4fa6-b336-d136dfad9b32:3ce20476d46749699bf38773b8798ace [I 13:06:37.279 NotebookApp] hide_code: Starting Latex PDF export for None [E 13:06:37.280 NotebookApp] Uncaught exception GET /notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/latexpdf (127.0.0.1) HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/latexpdf', version='HTTP/1.1', remote_ip='127.0.0.1') Traceback (most recent call last): File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/tornado/web.py", line 1701, in _execute result = method(self.path_args, **self.path_kwargs) File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/hide_code/hide_code.py", line 58, in get with open(ipynb_file_name(args), encoding="utf-8") as f: NotADirectoryError: [Errno 20] Not a directory: '/home/sage/pdf Test.ipynb/pdf Test.ipynb' [E 13:06:37.288 NotebookApp] { "Host": "localhost:8888", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Referer": "http://localhost:8888/notebooks/pdf%20Test.ipynb", "Cookie": "_xsrf=2|dd0b195e|6633b2d6953f663419dda408cee6e5b4|1608076637; username-localhost-8888="2|1:0|10:1609869964|23:username-localhost-8888|44:Mzc0MjQ2NjY0YWFjNDA2Y2JlNmEzMzViMzQ5NDYzNzI=|fda90676242fc02e229ee5b3e3c62361d2f6b471bf6c07ff792620114f16acaf"", "Upgrade-Insecure-Requests": "1" } [E 13:06:37.289 NotebookApp] 500 GET /notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/latexpdf (127.0.0.1) 9.45ms referer=http://localhost:8888/notebooks/pdf%20Test.ipynb [I 13:06:37.294 NotebookApp] Restoring connection for 43385a78-dbf0-4fa6-b336-d136dfad9b32:3ce20476d46749699bf38773b8798ace [I 13:06:37.301 NotebookApp] Starting buffering for 43385a78-dbf0-4fa6-b336-d136dfad9b32:3ce20476d46749699bf38773b8798ace [I 13:06:40.073 NotebookApp] Discarding 3 buffered messages for 43385a78-dbf0-4fa6-b336-d136dfad9b32:3ce20476d46749699bf38773b8798ace [I 13:06:45.468 NotebookApp] Starting buffering for 43385a78-dbf0-4fa6-b336-d136dfad9b32:d5c174cfd6d74c288513c4376e0ca1cc [I 13:06:45.472 NotebookApp] hide_code: Starting PDF export for None [E 13:06:45.474 NotebookApp] Uncaught exception GET /notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/pdf (127.0.0.1) HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/pdf', version='HTTP/1.1', remote_ip='127.0.0.1') Traceback (most recent call last): File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/tornado/web.py", line 1701, in _execute result = method(self.path_args, **self.path_kwargs) File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/hide_code/hide_code.py", line 42, in get with open(ipynb_file_name(args), encoding="utf-8") as f: NotADirectoryError: [Errno 20] Not a directory: '/home/sage/pdf Test.ipynb/pdf Test.ipynb' [E 13:06:45.476 NotebookApp] { "Host": "localhost:8888", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Referer": "http://localhost:8888/notebooks/pdf%20Test.ipynb", "Cookie": "_xsrf=2|dd0b195e|6633b2d6953f663419dda408cee6e5b4|1608076637; username-localhost-8888="2|1:0|10:1609869964|23:username-localhost-8888|44:Mzc0MjQ2NjY0YWFjNDA2Y2JlNmEzMzViMzQ5NDYzNzI=|fda90676242fc02e229ee5b3e3c62361d2f6b471bf6c07ff792620114f16acaf"", "Upgrade-Insecure-Requests": "1" } [E 13:06:45.477 NotebookApp] 500 GET /notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/pdf (127.0.0.1) 4.37ms referer=http://localhost:8888/notebooks/pdf%20Test.ipynb [I 13:06:45.481 NotebookApp] Restoring connection for 43385a78-dbf0-4fa6-b336-d136dfad9b32:d5c174cfd6d74c288513c4376e0ca1cc [I 13:06:45.487 NotebookApp] Starting buffering for 43385a78-dbf0-4fa6-b336-d136dfad9b32:d5c174cfd6d74c288513c4376e0ca1cc [I 13:06:52.804 NotebookApp] Starting buffering for 43385a78-dbf0-4fa6-b336-d136dfad9b32:375040d94db544128f8e23ce299f2209 [I 13:06:52.809 NotebookApp] hide_code: Starting HTML export for None [E 13:06:52.810 NotebookApp] Uncaught exception GET /notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/html (127.0.0.1) HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/html', version='HTTP/1.1', remote_ip='127.0.0.1') Traceback (most recent call last): File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/tornado/web.py", line 1701, in _execute result = method(self.path_args, **self.path_kwargs) File "/opt/sagemath-9.2/local/lib/python3.7/site-packages/hide_code/hide_code.py", line 27, in get with open(ipynb_file_name(args), encoding="utf-8") as f: NotADirectoryError: [Errno 20] Not a directory: '/home/sage/pdf Test.ipynb/pdf Test.ipynb' [E 13:06:52.813 NotebookApp] { "Host": "localhost:8888", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Referer": "http://localhost:8888/notebooks/pdf%20Test.ipynb", "Cookie": "_xsrf=2|dd0b195e|6633b2d6953f663419dda408cee6e5b4|1608076637; username-localhost-8888="2|1:0|10:1609869964|23:username-localhost-8888|44:Mzc0MjQ2NjY0YWFjNDA2Y2JlNmEzMzViMzQ5NDYzNzI=|fda90676242fc02e229ee5b3e3c62361d2f6b471bf6c07ff792620114f16acaf"", "Upgrade-Insecure-Requests": "1" } [E 13:06:52.815 NotebookApp] 500 GET /notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/html (127.0.0.1) 4.81ms referer=http://localhost:8888/notebooks/pdf%20Test.ipynb [I 13:06:52.848 NotebookApp] Restoring connection for 43385a78-dbf0-4fa6-b336-d136dfad9b32:375040d94db544128f8e23ce299f2209 [I 13:06:52.851 NotebookApp] Starting buffering for 43385a78-dbf0-4fa6-b336-d136dfad9b32:375040d94db544128f8e23ce299f2209

`

towight avatar Jan 05 '21 18:01 towight

The export URLs are wrong for some reason.

[E 13:06:52.810 NotebookApp] Uncaught exception GET /notebooks/pdf%20Test.ipynb/pdf%20Test.ipynb/export/html (127.0.0.1)

The correct export path should be /notebooks/pdf%20Test.ipynb/export/html. Are you triggering the export via hide_code export menu?

kirbs- avatar Jan 07 '21 14:01 kirbs-

I had noticed the duplication before, but didn't know if it was an error or a result of some arcane programming requirement. At any rate, I have been using the button on the toolbar to trigger the export, but it makes no difference if I use the hide_code drop down menu. (I think I misinterpreted your question but the answer still serves). Tom W.

towight avatar Jan 07 '21 18:01 towight

Similar issue here with version 0.6 on Windows : [E 12:00:25.953 NotebookApp] Uncaught exception GET /notebooks/Analyses%20managers.ipynb/Analyses%20managers.ipynb/export/html (::1) HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/Analyses%20managers.ipynb/Analyses%20managers.ipynb/export/html', version='HTTP/1.1', remote_ip='::1') Traceback (most recent call last): File "d:\users\feltincle\documents\portable\wpy64-3720\python-3.7.2.amd64\lib\site-packages\tornado\web.py", line 1702, in _execute result = method(self.path_args, **self.path_kwargs) File "d:\users\feltincle\documents\portable\wpy64-3720\python-3.7.2.amd64\lib\site-packages\hide_code\hide_code.py", line 27, in get with open(ipynb_file_name(args), encoding="utf-8") as f: FileNotFoundError: [Errno 2] No such file or directory: 'D:\Users\feltincle\Documents\Projets_Python\RH sondage\Analyses managers.ipynb\Analyses managers.ipynb' [E 12:00:25.960 NotebookApp] { "Host": "localhost:8888", "Connection": "keep-alive", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Edg/88.0.705.50", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Sec-Fetch-Site": "same-origin", "Sec-Fetch-Mode": "navigate", "Sec-Fetch-User": "?1", "Sec-Fetch-Dest": "document", "Referer": "http://localhost:8888/notebooks/Analyses%20managers.ipynb", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "fr,fr-FR;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", "Cookie": "_xsrf=2|cd1a1060|c25b9b62285adbd63099a97cc87df6df|1615293291; username-localhost-8888="2|1:0|10:1615557786|23:username-localhost-8888|44:NmVmNDQxNjhmNjcwNGIyZWI0NDdlOThkZDU5Mzc0YjA=|b0ad9526c40e7b2b9c6eed0c98dbba8a7c91a1e7c547b2f185416c5144ac11c3"" }

ClementFeltin avatar Mar 22 '21 13:03 ClementFeltin