Bug on building the example from Jupyter Book

Hi all,
I was trying to test Jupyter Books to convert my notebooks and my .md files into a nice readable piece, but I am failing on installing it, and so far I havent found why.
I am following the steps provided in https://jupyterbook.org/intro.html but I cant execute this command jupyter-book build ./mini_book. It always give me an error related with encoding problems, and to modules e.g. matplotlib. This last error I dont understand because I installed an environment that has all these packages before invoking the book build command.

This is very frustating because I am only following the steps they propose with a dummy test that does not work.

If you can give some hints of what is maybe happening it will be of great help!

Leila

Ah, nice, I meant to switch my stuff to jupyterbooks some time soon!

Can you share the more detailed error messages?

So this is what appears after I run the command.
Basically a lot of warnings and an error with Sphinx .
I can also upload a Bug report issue to the Github repo, but if you have an idea , it will much better.
Thanks!

$ jupyter-book build ./mini_book
?[01mRunning Sphinx v2.4.4?[39;49;00m
?[01mbuilding [mo]: ?[39;49;00mtargets for 0 po files that are out of date
?[01mbuilding [html]: ?[39;49;00mtargets for 5 source files that are out of date
?[01mupdating environment: ?[39;49;00mExecuting: C:\Users\linigodelacruz\quantecon-mini-example\mini_book\docs\getting_started.md
Executing: C:\Users\linigodelacruz\quantecon-mini-example\mini_book\docs\learn_more.md
Executing: C:\Users\linigodelacruz\quantecon-mini-example\mini_book\docs\python_by_example.md
[new config] 5 added, 5 changed, 0 removed
?[01mchecking for C:\Users\linigodelacruz\quantecon-mini-example\mini_book\_bibliography\references.bib in bibtex cache... ?[39;49;00mnot found
?[01mparsing bibtex file C:\Users\linigodelacruz\quantecon-mini-example\mini_book\_bibliography\references.bib... ?[39;49;00mparsed 2 entries
?[01mreading sources... ?[39;49;00m[100%] ?[35mdocs/python_by_example?[39;49;00m
?[31mWARNING: Execution Failed: C:\Users\linigodelacruz\quantecon-mini-example\mini_book\docs\getting_started.md?[39;49;00m
?[31mWARNING: Execution Failed: C:\Users\linigodelacruz\quantecon-mini-example\mini_book\docs\learn_more.md?[39;49;00m
?[31mWARNING: Execution Failed: C:\Users\linigodelacruz\quantecon-mini-example\mini_book\docs\python_by_example.md?[39;49;00m
?[31mWARNING: Couldn't find cache key for notebook file mini_book\docs\getting_started.md. Outputs will not be inserted.
  Last execution failed with traceback saved in C:\Users\linigodelacruz\quantecon-mini-example\mini_book\_build\html/reports/getting_started.log?[39;49;00m
?[31mWARNING: Couldn't find cache key for notebook file mini_book\docs\learn_more.md. Outputs will not be inserted.
  Last execution failed with traceback saved in C:\Users\linigodelacruz\quantecon-mini-example\mini_book\_build\html/reports/learn_more.log?[39;49;00m
?[31mWARNING: Couldn't find cache key for notebook file mini_book\docs\python_by_example.md. Outputs will not be inserted.
  Last execution failed with traceback saved in C:\Users\linigodelacruz\quantecon-mini-example\mini_book\_build\html/reports/python_by_example.log?[39;49;00m

?[31;01mSphinx error:?[39;49;00m
master file C:\Users\linigodelacruz\quantecon-mini-example\mini_book\docs\index.md not found

this is my environment info , if useful

     active environment : qe-mini-example
    active env location : C:\Users\linigodelacruz\AppData\Local\Continuum\anaconda3\envs\qe-mini-example
            shell level : 2
       user config file : C:\Users\linigodelacruz\.condarc
 populated config files : C:\Users\linigodelacruz\.condarc
          conda version : 4.8.3
    conda-build version : 3.15.1
         python version : 3.7.7.final.0
       virtual packages :
       base environment : C:\Users\linigodelacruz\AppData\Local\Continuum\anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\linigodelacruz\AppData\Local\Continuum\anaconda3\pkgs
                          C:\Users\linigodelacruz\.conda\pkgs
                          C:\Users\linigodelacruz\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\linigodelacruz\AppData\Local\Continuum\anaconda3\envs
                          C:\Users\linigodelacruz\.conda\envs
                          C:\Users\linigodelacruz\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.8.3 requests/2.23.0 CPython/3.7.7 Windows/10 Windows/10.0.17763
          administrator : False
             netrc file : None
           offline mode : False

OK, looks sufficiently confusing.

  • Can you also check the log files linked in the Last execution failed with traceback saved in ... lines?
  • Can you verify whether mini_book/docs/index.md actually exists in your files? It seems to be present in the original repository.

Yeah , I know :smirk:

question 1: Yes , I checked , and it is where the problems with the modules start to appear:
In learn_more.log

nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
from sympy import Symbol

x, y = Symbol('x'), Symbol('y')  # Treat 'x' and 'y' as algebraic symbols
x + x + x + y
------------------
ModuleNotFoundError: No module named 'sympy'

In Getting_started.log

nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
import numpy as np
import matplotlib.pyplot as plt



# Fixing random state for reproducibility
np.random.seed(19680801)

# Compute pie slices
N = 20
phi = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
radii = 10 * np.random.rand(N)
width = np.pi / 4 * np.random.rand(N)
colors = plt.cm.viridis(radii / 10.)

ax = plt.subplot(111, projection='polar')
ax.bar(phi, radii, width=width, bottom=0.0, color=colors, alpha=0.5)

plt.show()
------------------
ModuleNotFoundError: No module named 'matplotlib'

In python_by_example.log

nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
import numpy as np
import matplotlib.pyplot as plt

ϵ_values = np.random.randn(100)
plt.plot(ϵ_values)
plt.show()
------------------
ModuleNotFoundError: No module named 'matplotlib'

Question 2:

linigodelacruz@TUD256635 MINGW64 ~
$ cd quantecon-mini-example/

linigodelacruz@TUD256635 MINGW64 ~/quantecon-mini-example (master)
$ ls
environment.yml  mini_book/  README.md  requirements.txt

linigodelacruz@TUD256635 MINGW64 ~/quantecon-mini-example (master)
$ cd mini_book/

linigodelacruz@TUD256635 MINGW64 ~/quantecon-mini-example/mini_book (master)
$ ls
_bibliography/  _build/  _config.yml  _static/  _toc.yml  docs/  qe-logo-large.png

linigodelacruz@TUD256635 MINGW64 ~/quantecon-mini-example/mini_book (master)
$ cd docs/

linigodelacruz@TUD256635 MINGW64 ~/quantecon-mini-example/mini_book/docs (master)
$ ls
about_py.md  getting_started.md  **index.md**  learn_more.md  python_by_example.md  quant-econ.bib

It should be there because I cloned the original repository…

Odd, it should pick up the correct environment, and I have confirmed that following the instructions works for me.

As the next step, you can check whether jupyter-book (or rather the package jupyter-cache does pick up the right kernel by:

  1. removing all code from the markdown files
  2. inserting
    ```{code-cell} ipython3
    import sys
    print(sys.executable)
    ```
    
    in the file, and seeing what is produced.

In which file should I insert this code? In all .md files ?

Pick your favorite (e.g. replace some of the code that fails).

1 Like

It looks like I am basically screw… because I am using Windows :unamused: Look at this issue

1 Like

Ah, that’s too bad.

You can try windows subsystem for linux as a workaround until the executable books team irons out the windows bugs.

Now it finally works!! :star_struck: Here a link to the issue where all guidelines are described for Windows : https://github.com/phaustin/jupyter-book/blob/windows/docs/advanced/advanced.md#working-on-windows
It is just doing this:

Summary

The following workflow should succeed using a miniconda powershell terminal on Windows 10:

  1. conda install git
  2. git clone https://github.com/eoas-ubc/quantecon-mini-example.git
  3. cd quantecon-mini-example
  4. git checkout windows
  5. conda env create -f environment_win.yml
  6. conda activate wintest
  7. cd mini_book
  8. runjb docs

After the build, view the html with:

start docs\_build\html\index.html

1 Like

Wow, that’s a whole lot of workarounds! Great that it finally works!

1 Like

@Leila it seems your bug report set in motion a chain of events that landed on my desk. So it seems that my prior inaction was one of the reasons of the bug that you encountered :rofl:

A lot of interesting stuffs has happened hahahaha

Hi,

I am also experiencing problems with building the mini-book.
Similar to Leila, I also started with the demo book from Jupyter Book.
When I run the command (in anaconda prompt):

(wintest) C:\Users\luuka\quantecon-mini-example>jupyter-book build ./mini_book

It returns the following error:

Running Jupyter-Book v0.8.3
Traceback (most recent call last):
File “c:\users\luuka\anaconda3\envs\wintest\lib\runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “c:\users\luuka\anaconda3\envs\wintest\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File "C:\Users\luuka\Anaconda3\envs\wintest\Scripts\jupyter-book.exe_main
.py", line 7, in
File “c:\users\luuka\anaconda3\envs\wintest\lib\site-packages\click\core.py”, line 829, in call
return self.main(*args, **kwargs)
File “c:\users\luuka\anaconda3\envs\wintest\lib\site-packages\click\core.py”, line 782, in main
rv = self.invoke(ctx)
File “c:\users\luuka\anaconda3\envs\wintest\lib\site-packages\click\core.py”, line 1259, in invoke
return process_result(sub_ctx.command.invoke(sub_ctx))
File “c:\users\luuka\anaconda3\envs\wintest\lib\site-packages\click\core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “c:\users\luuka\anaconda3\envs\wintest\lib\site-packages\click\core.py”, line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\luuka\anaconda3\envs\wintest\lib\site-packages\jupyter_book\commands_init
.py", line 199, in build
build_modified = max([os.stat(ii).st_mtime for ii in build_files])
ValueError: max() arg is an empty sequence

Does anybody have an idea what I could do to fix this?

Let’s see if I can make sense of it. The line that is run checks when the file was last modified out of build_files, and then the function max complains that it’s called on an empty sequence (you can reproduce the same error by calling max([]) with an empty list as an argument.

Given that the variable name is build_files, it seems that you’re trying to build an empty jupyter book, could that be the case? Does the mini_book folder contain files to be built?

Hi Anton,

I tried a different demo book:

In anaconda prompt I created a demo book by: jupyter-book create mynewbook/

It created a directory ‘newbook’ with the following files: https://github.com/luukalt/shared/blob/main/newbook.zip

When I try to build this book it gives me the same error as before.
I believe this example contains build files, so maybe it is a windows issue (I also tried on another windows PC -> same error).

Thanks for the help,
Luuk

At a glance looks like it should work. I suggest reporting a bug to the jupyter book team.

I reported the bug, but unfortunately still no answer.