Jupyterbook: Live Code not importing Scipy library

Hi:

I am using a simple code in jupyter-book using Live Code (Thebe). It is a markdown file that runs perfectly in jupyterlab, and also, the jupyter-book builds without errors. But, if I try to run the code using “Live Code” it does not find the scipy library.

This is the code:

##########################
N = 100    # Tamaño muestra
M = 10      # Número de intervalos
##########################

import numpy as np
import pylab as plt
from scipy.stats import norm
plt.rcParams.update({'font.size': 16})

np.random.seed(0)
conjunto = np.random.normal(loc=0,scale=1,size=N)
infoHist = plt.hist(conjunto,bins=M,density=True,align='left',
                   color='silver')
x = np.linspace(-5,5,100)
plt.plot(x,norm.pdf(x,loc=0,scale=1),color='r',label=r'$f(x)$')
plt.title(r'N = {}, M = {}'.format(N,M))
plt.xlabel(r'$x_i$')
plt.ylabel(r'$f_i$')
plt.legend()
plt.show()

This is the error message:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_46/1496607146.py in <module>
      7 import numpy as np
      8 import pylab as plt
----> 9 from scipy.stats import norm
     10 plt.rcParams.update({'font.size': 16})
     11 

ModuleNotFoundError: No module named 'scipy'

The scipy version is 1.7.3
The jupyter-book version 0.13.0

I appreciate any help you can give me.

Regards

ER

I just run the code today, now it compile correctly. It was a one day problem.

I did not change anything, just run it few days later.

1 Like