Re: Python Integration #jupyter


James Bergeron
 

No answer. 
Later I tried inserting some different, non input related code and the error related to not being able to import Sympy returned. Perhaps the two issues are related. 
I've been working successfully outside of the libretext environment with jupyter in the last few days, while waiting for ideas.  
You can pass on my contact info if the Jupyter people want it. 
Thanks in advance, 
James



On Mon., Feb. 10, 2020, 10:36 p.m. Delmar Larsen via Groups.Io <dlarsen=libretexts.org@groups.io> wrote:

Dear James:

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

Delmar

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">'
%%python3
 
'</pre>

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

foo gets printed, what I will assume is normally (60-90 second delay for response).
Woo gets printed, but immediately spits out the following:
foo
Woo?
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/interactiveshell.py 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
   2354 
 
/srv/conda/lib/python3.7/site-packages/IPython/core/magics/script.py in named_script_magic(line, cell)
    140             else:
    141                 line = script
--> 142             return self.shebang(line, cell)
    143 
    144         # write a basic docstring:
 
</srv/conda/lib/python3.7/site-packages/decorator.py:decorator-gen-110> in shebang(self, line, cell)
 
/srv/conda/lib/python3.7/site-packages/IPython/core/magic.py 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)
    188 
    189         if callable(arg):
 
/srv/conda/lib/python3.7/site-packages/IPython/core/magics/script.py 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)
    246 
    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
https://LibreTexts.org
The Future is Open

Weekly Libretexts Office Hours Zoom meetings (open to all): 
  * Tuesdays (https://zoom.us/j/380504419) at 9:00am (PDT)
  * Thursdays (https://zoom.us/j/662384088) at 9:00am (PDT)

Join main@Libretexts-ConstructionForum.groups.io to automatically receive all group messages.