Re: Python Integration #jupyter

Delmar Larsen <dlarsen@...>

Dear James:

Did you get an answer to your question? I can follow up with the jupyter people if not.


On 2/4/2020 8:21 PM, James Bergeron wrote:
I follow the construction guide steps for inserting a jupyter notebooks template into a libretext page.  
It yields a blank DekiScript section with the following code:
<pre ('data-jupyter')="true">'

So far so good I think.  However, when I enter very simple code within the pre tags as follows:
name = input("Woo?")

foo gets printed, what I will assume is normally (60-90 second delay for response).
Woo gets printed, but immediately spits out the following:
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
EOFError: EOF when reading a line
CalledProcessError                        Traceback (most recent call last)
<ipython-input-1-6d09ad8b778b> in <module>
----> 1 get_ipython().run_cell_magic('python3', '', 'print("foo")\nname = input("Woo?")\nprint(name)\n')
/srv/conda/lib/python3.7/site-packages/IPython/core/ in run_cell_magic(self, magic_name, line, cell)
   2350             with self.builtin_trap:
   2351                 args = (magic_arg_s, cell)
-> 2352                 result = fn(*args, **kwargs)
   2353             return result
/srv/conda/lib/python3.7/site-packages/IPython/core/magics/ in named_script_magic(line, cell)
    140             else:
    141                 line = script
--> 142             return self.shebang(line, cell)
    144         # write a basic docstring:
</srv/conda/lib/python3.7/site-packages/> in shebang(self, line, cell)
/srv/conda/lib/python3.7/site-packages/IPython/core/ in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    189         if callable(arg):
/srv/conda/lib/python3.7/site-packages/IPython/core/magics/ in shebang(self, line, cell)
    243             sys.stderr.flush()
    244         if args.raise_error and p.returncode!=0:
--> 245             raise CalledProcessError(p.returncode, cell, output=out, stderr=err)
    247     def _run_script(self, p, cell, to_close):
CalledProcessError: Command 'b'print("foo")\nname = input("Woo?")\nprint(name)\n'' returned non-zero exit status 1.

I know that python can be used to read input (LibreText - engineering bookshelf, python course, input section).
My suspicion is there is a config setting for display somewhere that needs to be set, but where and in which system (DekiScript/LibreText)?

Anyone know how to fix this most basic of issues?
Delmar Larsen, Ph.D.
LibreText, Founder & Executive Director
The Future is Open

Weekly Libretexts Office Hours Zoom meetings (open to all): 
  * Tuesdays ( at 9:00am (PDT)
  * Thursdays ( at 9:00am (PDT)

Join to automatically receive all group messages.