jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.6k stars 4.87k forks source link

Mathjax js file not loading #1108

Closed moorepants closed 7 years ago

moorepants commented 8 years ago

I just loaded up a notebook that I last used with IPython < 4.0 and the MathJax math from SymPy output is failing to load. I'm getting this 404:

[W 16:47:28.747 NotebookApp] 404 GET /static/components/MathJax/jax/element/mml/optable/BasicLatin.js?rev=2.5.3 (127.0.0.1) 10.63ms referer=http://localhost:8888/notebooks/n01_dynamics_overview.ipynb

My previous method for installing MathJax was to do this:

In [1]: from IPython.external import mathjax
In [2]: mathjax.install_mathjax()

I see from some issues that that may not be correct anymore.

takluyver commented 8 years ago

The install_mathjax() function is gone, because MathJax should now be bundled with the notebook. How did you install/upgrade?

moorepants commented 8 years ago

I am using conda to upgrade IPython.

takluyver commented 8 years ago

Odd, that shouldn't have this issue. Can you dig into your installation directory and find out how much of the 404'd path is missing. It's rooted in the notebook package directory, i.e.:

import notebook
os.path.join(os.path.dirname(notebook.__file__), 'static/...')
moorepants commented 8 years ago

This is all I find in the jax dir:

moorepants@garuda:eme185-website(master)$ ls /home/moorepants/miniconda3/lib/python3.5/site-packages/notebook/static/components/MathJax/jax/
input  output

Here is the complete tree:

moorepants@garuda:eme185-website(master)$ tree /home/moorepants/miniconda3/lib/python3.5/site-packages/notebook/static/components/MathJax/jax/
/home/moorepants/miniconda3/lib/python3.5/site-packages/notebook/static/components/MathJax/jax/
├── input
│   └── TeX
│       ├── config.js
│       └── jax.js
└── output
    └── HTML-CSS
        ├── autoload
        │   ├── annotation-xml.js
        │   ├── maction.js
        │   ├── menclose.js
        │   ├── mglyph.js
        │   ├── mmultiscripts.js
        │   ├── ms.js
        │   ├── mtable.js
        │   └── multiline.js
        ├── config.js
        ├── fonts
        │   └── STIX-Web
        │       ├── Alphabets
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Arrows
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── DoubleStruck
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── fontdata-extra.js
        │       ├── fontdata.js
        │       ├── Fraktur
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Latin
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Main
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Marks
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Misc
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Monospace
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Normal
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   └── Italic
        │       │       └── Main.js
        │       ├── Operators
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── SansSerif
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Script
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   ├── Italic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Shapes
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   ├── BoldItalic
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Size1
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Size2
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Size3
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Size4
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Size5
        │       │   └── Regular
        │       │       └── Main.js
        │       ├── Symbols
        │       │   ├── Bold
        │       │   │   └── Main.js
        │       │   └── Regular
        │       │       └── Main.js
        │       └── Variants
        │           ├── Bold
        │           │   └── Main.js
        │           ├── BoldItalic
        │           │   └── Main.js
        │           ├── Italic
        │           │   └── Main.js
        │           └── Regular
        │               └── Main.js
        ├── imageFonts.js
        └── jax.js

83 directories, 70 files
takluyver commented 8 years ago

I see a similar set of files. So I think you have the right files, but it's trying to load something it shouldn't. That could be because:

  1. The particular things you're displaying cause MathJax to try to load something extra
  2. There's something left over from a previous version (e.g. in browser cache) that's interfering.

To test 1: does Mathjax work on other things, like a simple $x=1$ in a Markdown cell?

To test 2: try running the notebook server with --port 8999 (or any number other that the normal port), which should avoid browser cache.

mforbes commented 8 years ago

I have been having the issue with /static/components/MathJax/jax/element/mml/optable/BasicLatin.js not being found on Mac OS X with the conda install of notebook etc. Basic math works, and it is not a cache issue (using a different port has the same problem.) Seems to be an issue on fresh python 2 and 3 environments.

stsievert commented 8 years ago

Same issue here, persists through fresh anaconda install. My notebook doesn't work under Safari but works under Chrome. I tried emptying the cache and restarting the browser, but no luck.

My error message:

[W 22:48:18.498 NotebookApp] 404 GET /static/components/MathJax/jax/output/SVG/fonts/TeX/fontdata.js?rev=2.6.0

I'm using Python 3.5 on OS X 10.11.4.

EDIT: I have since solved the problem. It required clearing all website data through "Settings > Privacy > Remove all website data" instead of removing the cache through "Develop > Empty caches".

updiversity commented 8 years ago

I am having a similar issue, but with another Mathjax library : mathchoice.js

python -c "import IPython; print(IPython.sys_info())"         
{'commit_hash': '1ba246d',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/home/vagrant/.virtualenvs/venvpy3/lib/python3.4/site-packages/IPython',
 'ipython_version': '5.0.0',
 'os_name': 'posix',
 'platform': 'Linux-3.13.0-45-generic-x86_64-with-Ubuntu-14.04-trusty',
 'sys_executable': '/home/vagrant/.virtualenvs/venvpy3/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.4.3 (default, Jul 28 2015, 18:20:59) \n[GCC 4.8.4]'}
os.path.join(os.path.dirname(notebook.__file__), 'static/...')
Out[3]: '/home/vagrant/.virtualenvs/venvpy3/lib/python3.4/site-packages/notebook/static/...'
rtbs-dev commented 8 years ago

I'm having a similar issue,

[W 20:22:36.138 NotebookApp] 404 GET /static/components/MathJax/jax/output/SVG/fonts/TeX/fontdata.js?rev=2.6.0 (::1)

Everything seems to be working, except for rendering to SVG. Would be helpful for porting some equations from my RISE presentation to a ppt. Choosing that gets a [Math Processing Error]

takluyver commented 8 years ago

We do remove some rendering options from Mathjax to keep the package size down - that may have been one of those.

ralexx commented 8 years ago

Similar 404 error using notebook 4.2.3, jupyter_core 4.2.0.

[W 12:56:03.971 NotebookApp] 404 GET /static/components/MathJax/jax/element/mml/optable/BasicLatin.js?rev=2.6.0 (::1) 7.89ms referer=http://localhost:8888/path/mynotebook.ipynb

I fixed it by copying the .../element directory from Anaconda's Spyder package into /usr/local/share/anaconda/lib/python3.5/site-packages/notebook/static/components/MathJax/jax.

On my system, .../element/* sums to about 135 KB. Perhaps worth including in Notebook's version?

/usr/local/share/anaconda/lib/python3.5/site-packages/spyderlib/utils/inspector/js/mathjax/jax
├── element
│   └── mml
│       ├── jax.js
│       └── optable
│           ├── Arrows.js
│           ├── BasicLatin.js
│           ├── CombDiacritMarks.js
│           ├── CombDiactForSymbols.js
│           ├── Dingbats.js
│           ├── GeneralPunctuation.js
│           ├── GeometricShapes.js
│           ├── GreekAndCoptic.js
│           ├── Latin1Supplement.js
│           ├── LetterlikeSymbols.js
│           ├── MathOperators.js
│           ├── MiscMathSymbolsA.js
│           ├── MiscMathSymbolsB.js
│           ├── MiscSymbolsAndArrows.js
│           ├── MiscTechnical.js
│           ├── SpacingModLetters.js
│           ├── SuppMathOperators.js
│           ├── SupplementalArrowsA.js
│           └── SupplementalArrowsB.js
├── input
[...]
└── output
jat255 commented 7 years ago

I had this same problem:

404 GET /static/components/MathJax/jax/output/SVG/fonts/TeX/fontdata.js?rev=2.6.0

Workaround was to copy the ../TeX folder from another MathJax installation into the right spot in the notebook folder within site-packages.

takluyver commented 7 years ago

It looks like people have reported several similar but distinct errors here. I suspect it may depend on what math you're displaying in the notebook. Does anyone have a sample notebook that consistently reproduces the error?

linas commented 7 years ago

In my case, there's a distro dependency: I'm running Debian testing, mathjax is installed in /usr/share/javascript/mathjax/ and is provided by the libjs-mathjax debian package. There is no mathjax under any directory called notebook or jupyter that I can find. This more or less makes sense: you would not want to install two copies of mathjax: one in jupyter, another that is a system-wide version.

However, this points to a package-maintainance bug; in my case, the error is far more basic:

[W 17:50:59.672 NotebookApp] 404 GET /static/components/MathJax/fonts/HTML-CSS/STIX-Web/woff/STIXMathJax_Main-Italic.woff?V=2.7.0 (127.0.0.1) 2.31ms 

and STIX is simply just not installed... because debian doesn't package STIX. go figure.

takluyver commented 7 years ago

@linas That sounds like an issue with Debian's packaging. We recommend installing the notebook with pip or conda, because Debian's version will often be out of date. Or even broken, apparently. ;-)

If you want to use Debian's packages, here is where to file bugs against them.

takluyver commented 7 years ago

Actually, it looks like Debian packages symlink mathjax in.

linas commented 7 years ago

Thanks, yes, sorry, I think I just confused the original issue. Side comment: I searched high & wide for a debian package containing STIX fonts, and found none. Installing them by hand did not solve my other issues, so my comments are a red herring.

ralexx commented 7 years ago

@takluyver To consistently reproduce the error try this notebook. Heavy use of TeX, triggers the following 404 errors for me:

[W 22:44:04.464 NotebookApp] 404 GET /static/components/MathJax/jax/element/mml/optable/BasicLatin.js?rev=2.6.0 (::1) 1.78ms referer=http://localhost:8888/index.ipynb
[W 22:44:05.629 NotebookApp] 404 GET /static/components/MathJax/jax/element/mml/optable/MathOperators.js?rev=2.6.0 (::1) 1.56ms referer=http://localhost:8888/index.ipynb
[W 22:44:26.582 NotebookApp] 404 GET /static/components/MathJax/fonts/HTML-CSS/TeX/otf/MathJax_AMS-Regular.otf (::1) 1.65ms referer=http://localhost:8888/index.ipynb
[W 22:44:26.584 NotebookApp] 404 GET /static/components/MathJax/fonts/HTML-CSS/TeX/otf/MathJax_Script-Regular.otf (::1) 1.43ms referer=http://localhost:8888/index.ipynb

I am now on Jupyter 4.3, Jupyter Notebook 5.0.

OpenWaygate commented 5 years ago

I have the same issue and solved it!

_404 GET /static/components/MathJax/jax/output/CommonHTML/fonts/TeX/fontdata.js?V=_2.7.5

go to MathJax release page download MathJax 2.7.5 copy the file in MathJax-2.7.5\jax just downloaded to python37\Lib\site-packages\notebook\ static\components\MathJax\jax and the notebook work well when renderer formula to svg!

image

For the error message which not refer to this path, just copy&paste with corresponding path.