Skip to content

Symbolic link causes problems with images in output cells #49

Open

Description

@twiecki

For example: http://pymc-devs.github.io/pymc3/notebooks/BEST.html
Tries to link to: http://pymc-devs.github.io/pymc3/notebooks/_build/doctrees/nbsphinx/notebooks_BEST_8_0.png

During compilation I get many warnings like:
/home/wiecki/working/projects/pymc/docs/source/notebooks/survival_analysis.ipynb:193: WARNING: image file not readable: notebooks/../_build/doctrees/nbsphinx/notebooks_survival_analysis_11_0.png

I have seen #9 which looks very related and installed from master to make sure #10 was included but those don't fix this issue.

Activity

  1. springcoil commented on May 23, 2016

    @springcoil

    No idea how to debug that - do you want to merge WIP already or wait for the fix?

  2. mgeier commented on May 23, 2016

    @mgeier
    Member

    I don't think #9 and #10 have anything to do with that.

    The problem seems to be that when Sphinx reads the intermediate reST file, which contains image links in the form notebooks/../_build/doctrees/nbsphinx/*.png, it apparently doesn't follow the symlink back to the source directory but it applies the .. to the symlink-free original location on the file system (which would actually make sense if this were in a real reST file). Therefore, it doesn't find the intermediate directory where the image files are stored.

    This will hopefully be solved with #36, but I'm afraid this won't happen very soon.

    In the meantime I guess I'll have to make some kind of work-around, any ideas how to tackle this?

  3. mgeier commented on May 23, 2016

    @mgeier
    Member

    Correction: The intermediate reST file contains links like this: ../_build/doctrees/nbsphinx/*.png, but Sphinx somehow prepends the directory notebooks/, which contains the source file.
    I guess it's actually the operating system that resolves the .. part.

  4. twiecki commented on May 23, 2016

    @twiecki
    Author

    It seemed to ultimately work in #9, what is different about my usecase? Would it help if I moved the NBs out of the subdirectory? The same problem persists locally.

  5. mgeier commented on May 23, 2016

    @mgeier
    Member

    The problem is the symbolic link. It should work if you actually move the files to a "real" subdirectory docs/source/notebooks/. If you want, you can then make a symbolic link in the other direction, back to the original place pymc3/examples/notebooks/.

  6. changed the title [-]matplotlib plots do not show up[/-] [+]Symbolic link seems to cause problems with paths to images[/+] on May 23, 2016
  7. changed the title [-]Symbolic link seems to cause problems with paths to images[/-] [+]Symbolic link causes problems with images in output cells[/+] on May 24, 2016
  8. mgeier commented on May 24, 2016

    @mgeier
    Member

    Good to know that the work-around helps. I changed the title to mention that the problem occurs in output cells. There shouldn't be any problems with images in Markdown cells.

  9. twiecki commented on Jul 15, 2016

    @twiecki
    Author

    Any solution to this? Having the NB directory live in the doc subdir is a bit unwieldy.

  10. mgeier commented on Jul 16, 2016

    @mgeier
    Member

    Sorry, I don't know how to solve this before #36. But I'm open to suggestions!

    If you don't want to move the NB dir into the doc dir, you can do it the other way round, by moving conf.py to your main directory (and then use master_doc = 'doc/index'). Would this be less unwieldy?

  11. twiecki commented on Jul 16, 2016

    @twiecki
    Author

    Thanks for the suggestion. conf.py as well as Makefile, right?

  12. mgeier commented on Jul 16, 2016

    @mgeier
    Member

    The Makefile is optional and IMHO not necessary. But if you want to use the auto-generated Makefile as is, I guess you'll have to move it, too. But I don't think that's a good idea since people might think that's a Makefile for the whole program/library, not only for the docs.

    You could of course create a custom Makefile and put it anywhere you want, or you could manually call sphinx-build every time, or create a simple shell script, or ...

    The IMHO nicest solution would be to use BuildDoc in your setup.py, then you could generate the docs by simply running:

    python3 setup.py build_sphinx
    

    In this case, you wouldn't even need to move your conf.py, since you could specify its location in setup.py.

    If you want to go that way and need more information, don't hesitate to ask.

  13. twiecki commented on Jul 18, 2016

    @twiecki
    Author

    Thanks @mgeier. I think I'm making some progress: pymc-devs/pymc#1245

    The problem is that build/sphinx directory where the compiled docs get stored does not contain index.html and the other master level files in the root directory but build/sphinx/html/docs/source. Any idea on how to fix that?

  14. mgeier commented on Jul 19, 2016

    @mgeier
    Member

    I didn't think about this before, but I guess it makes sense that the output directory is laid out like this (mirroring the source directory).

    You could try to move index.rst to the main directory, too, but at some point it will get crowded ...

    To get nicer URLs for the other pages, you should probably get rid of the sources/ subdirectory.

  15. johannes-mueller commented on Nov 7, 2019

    @johannes-mueller

    It works for me when I create a real directory notebooks/ in the sources/ subdirectory and in there have symlinks to the individual notebooks.

    I think that's a feasible workaround.

  16. valeriupredoi commented on Mar 13, 2025

    @valeriupredoi

    It works for me when I create a real directory notebooks/ in the sources/ subdirectory and in there have symlinks to the individual notebooks.

    I think that's a feasible workaround.

    cheers muchly, mate! This issue still bites, but your suggestion works perfectly fine 🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions