Python Integration #jupyter


James Bergeron
 

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 <dlarsen@...>
 

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)


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)


Jason K. Moore
 

James,

Note that the integration with Libretexts pages is not yet supported. We setup a demo to get the DoE grant and I've asked for that to be disabled numerous times, as we are not supporting it. It is still live it seems and confusing people.

But, we are very close to launching the officially supported page integration. It will likely be ready in one more month (at least that is our goal). We are developing a proper plugin for the editor. Here are the issues we are tackling now for the new plugin:


Our broader page integration issues are also tracked here:


We will post to this forum once it is live and ready for use.

If you are having trouble with jupyter.libretexts.org, we can help with that, as it is officially supported.

Jason


Jason K. Moore, PhD
Faculty, Mechanical and Aerospace Engineering Department
University of California, Davis
faculty.engineering.ucdavis.edu/moore
jkm@...
530-752-4805



On Tue, Feb 11, 2020 at 5:11 AM James Bergeron <jberg475@...> wrote:
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)


Pamini Thangarajah
 

Thanks, Jason.

--
***********************************************************************
Pamini Thangarajah, PhD
Professor in Mathematics
Department of Mathematics and Computing
Mount Royal University
4825 Mount Royal Gate SW
Calgary, Alberta  T3E 6K6 
P: 403.440.6477
***********************************************************************


James Bergeron
 

Thanks Jason, if I may be of help to your group in testing, please let me know.
Regards,
James


Jason Moore
 

Great! We are going to demo the functionality in a webinar the week of March 2nd and will have you on the list as a tester!