Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"[Errno 2] No such file or directory" when a subdirectory is added #6

Closed
jhconning opened this issue Jan 15, 2016 · 6 comments
Closed

Comments

@jhconning
Copy link

Thanks for nbsphinx, this is going to be a really useful time-saving tool.

I am however running into an error that is causing me lots of confusion

C:\B\nbsphinx_mytest\docs>sphinx-build source build
Running Sphinx v1.3.4
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 3 source files that are out of date
updating environment: 3 added, 0 changed, 0 removed
reading sources... [100%] notebooks/notebook2
Exception occurred:
  File "c:\users\jonathan\anaconda3\lib\site-packages\nbsphinx.py", line 366, in parse
    with open(dest, 'wb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\B\\nbsphinx_mytest\\docs\\build\\.doctrees\\nbsphinx\\notebooks\\notebook2_4_0.png'
The full traceback has been saved in C:\Users\Jonathan\AppData\Local\Temp\sphinx-err-28u403cp.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

The log file is here (had to change .log to .txt to attach):
sphinx-err-28u403cp.txt

You can see the simple folder structure I have on nbsphinx_mytest repo -- displaying (now incorrectly) at http://nbsphinx-mytest.readthedocs.org/) that my ```index.rst''' is basically just:

.. toctree::
    :maxdepth: 3
    :glob:

    notebook1
    notebooks/*

and I have a single notebook2.ipynb (with a plot) inside the notebooks folder inside the source folder.

The extra bizarre thing about this is that even after I strip my index.rst of the glob and any reference to the subdirectory, so it's now nothing more than:

.. toctree::
    :maxdepth: 3

    notebook1

and I then rebuild (even after deleting the earlier build directory) I the same error now persists on a new build. It is as if nbsphinx is searching subfolders whether instructed to the earlier error is not being cleared out.

It may be relevant that it now says running Sphinx v1.3.4. Could that be a problem (because I'm pretty sure I'd not encountered this problem before when I was running similar experiments with subdirectories on v1.3.3). Worth noting that I'm now getting a similar type error when I clone this nbsphinx repo and run your examples with sphinx-build . build (it wasn't clear from the instructions if that's the right way).

mgeier added a commit that referenced this issue Jan 15, 2016
@mgeier
Copy link
Member

mgeier commented Jan 15, 2016

Thanks for the report!

The bizarre behavior you're reporting (which I also found a bit strange) is actually the expected behavior, AFAIK. Sphinx parses all source files in the source directory and its subdirectories, regardless if they are used in a toctree directive or not (it even includes them in HTML output!). Since nbsphinx "upgrades" Jupyter notebooks to Sphinx source files, they are parsed (and executed!), too.

To avoid unnecessary parsing and executing, you can add the unwanted files to exclude_patterns in conf.py (or just move them out of the source directory).

The actual error message you are mentioning is due to some differences in path handling between Unix and Windows. I don't know if the Sphinx version has anything to do with it.

Can you please check if #7 works for you on Windows?

The result on readthedocs.org should be correct anyway, right?

it wasn't clear from the instructions if that's the right way

Is it not clear from http://nbsphinx.readthedocs.org/en/latest/usage.html#Running-Sphinx?

It actually doesn't matter if you use build or _build or something else, the build directory is automatically created if it doesn't exist yet.

@jhconning
Copy link
Author

As mentioned on #7 that fixed the problem, thanks.

I am having a few remaining problems on the windows side such as plots not showing up (%5C rather than slash in links to .PNG files --- is there another place for a " os,sep to '/' " fix? ) But things do render correctly on readthedocs so I'm not that concerned..

I'll be back with a few short followup questions on build strategies (e.g. with notebooks outside the source directory) and a bit more info on those remaining windows problems (in case it's useful to anybody in similar predicament) but I need to process and experiment a bit first.

Thanks for the fast problem solving!

@mgeier
Copy link
Member

mgeier commented Jan 16, 2016

I'm glad that one of the problems is solved now!

Please create further issues for anything that doesn't work as expected.

The difference of path separator between Unix and Windows is often a source for problems ... sadly, there are no more os.sep in my code to fix ...
Please provide concrete examples where '/' is incorrectly turned into '%5C'.
I'm normally not working on a Windows system, therefore detailed information from you is very helpful.

@mgeier
Copy link
Member

mgeier commented Jan 16, 2016

Can you please check if #10 helps with your wrong links to PNGs?

@jhconning
Copy link
Author

Yes, #10 fixes the wrong links issue. Since your fixes in #7 and #10 solve all the windows build issues I was having, I'll close this (I hope it's proper etiquette for the person who brought up the issue, rather than the developer to close the issue). Thanks, this is going to be an essential tool.

@mgeier
Copy link
Member

mgeier commented Jan 17, 2016

Thanks for testing!
And yes, it's definitely proper etiquette for you to close your own issues. However, i'd normally wait until the PRs that fix the issue are actually merged into the "master" branch (because they might as well be closed without merging, leaving your issue unresolved once again).
But now both PRs are merged and everything is fine ...

mgeier added a commit that referenced this issue Feb 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants