Git Product home page Git Product logo

xonsh_kernel's Introduction

A Calysto Jupyter kernel for Xonsh.

To install:

pip install xonsh_kernel
python -m xonsh_kernel.install

To use it, run one of:

jupyter notebook
# In the notebook interface, select 'Calysto Xonsh' from the 'New' menu
ipython qtconsole --kernel calysto_xonsh
ipython console --kernel calysto_xonsh

This is based on MetaKernel, which means it features a standard set of %%magics. Note that this is different from the kernel that is distributed with Xonsh.

A sample notebook is available online.

xonsh_kernel's People

Contributors

blink1073 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xonsh_kernel's Issues

Testing on windows (anaconda installation)

Hi

I just tried this in my Anaconda distribution on windows.

I got the following error. I don't know if you expected it to work on windows, but I got the following ERROR. Maybe it is useful.

C:\Users\mel\Documents\GitHub\xonsh_kernel>ipython qtconsole --kernel=xonsh_kernel
---------------------------------------------------------------------------
TIMEOUT                                   Traceback (most recent call last)
C:\Users\mel\Anaconda3\lib\site-packages\metakernel-0.9.0-py3.4.egg\metakernel\pexpect.py in expect_loop(self=<metakernel.pexpect.Ex
pecter object>, timeout=-0.0007159709930419922)
    222                 if (timeout is not None) and (timeout < 0):
--> 223                     return self.timeout()
        self.timeout = <bound method Expecter.timeout of <metakernel.pexpect.Expecter object at 0x00000000048C4358>>
    224                 # Still have time left, so read more data

C:\Users\mel\Anaconda3\lib\site-packages\metakernel-0.9.0-py3.4.egg\metakernel\pexpect.py in timeout(self=<metakernel.pexpect.Expect
er object>, err=None)
    196                 msg = str(err) + '\n' + msg
--> 197             raise TIMEOUT(msg)
        global TIMEOUT = <class 'metakernel.pexpect.TIMEOUT'>
        msg = "<metakernel.pexpect.spawnu object at 0x00000000048C4278>\nversion: 3.3\ncommand: C:\\Users\\mel\\Anaconda3\\Scripts\\
xonsh.EXE\nargs: ['C:\\\\Users\\\\mel\\\\Anaconda3\\\\Scripts\\\\xonsh.EXE']\nsearcher: None\nbuffer (last 100 chars): ''\nbefore (l
ast 100 chars): ''\nafter: <class 'metakernel.pexpect.TIMEOUT'>\nmatch: None\nmatch_index: None\nexitstatus: None\nflag_eof: False\n
pid: 11372\nchild_fd: 7\nclosed: False\ntimeout: 30\ndelimiter: <class 'metakernel.pexpect.EOF'>\nlogfile: None\nlogfile_read: None\
nlogfile_send: None\nmaxread: 2000\nignorecase: False\nsearchwindowsize: None\ndelaybeforesend: 0.05\ndelayafterclose: 0.1\ndelayaft
erterminate: 0.1"
    198

TIMEOUT: <metakernel.pexpect.spawnu object at 0x00000000048C4278>
version: 3.3
command: C:\Users\mel\Anaconda3\Scripts\xonsh.EXE
args: ['C:\\Users\\mel\\Anaconda3\\Scripts\\xonsh.EXE']
searcher: None
buffer (last 100 chars): ''
before (last 100 chars): ''
after: <class 'metakernel.pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 11372
child_fd: 7
closed: False
timeout: 30
delimiter: <class 'metakernel.pexpect.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1

setup looking for non-existant file

Running setup.py on the lastest pull gives the following error:

Traceback (most recent call last):
  File "setup.py", line 29, in <module>
    with open('xonsh_kernel.py', 'rb') as fid:
FileNotFoundError: [Errno 2] No such file or directory: 'xonsh_kernel.py'

xonsh_kernel is now a directory rather than a self contained file.

Not attaching to xonsh installation

I installed with pip install xonsh_kernel on IPython 4.0, Python 3.5 (Anaconda on Linux Mint)

pip show xonsh-kernel says it's installed:


---
Metadata-Version: 2.0
Name: xonsh-kernel
Version: 0.1.0
Summary: An Xonsh kernel for Jupyter/IPython
Home-page: https://github.com/calysto/xonsh_kernel
Author: Steven Silvester
Author-email: [email protected]
License: MIT
Location: /home/louis/anaconda3/lib/python3.5/site-packages
Requires: metakernel, IPython

But no entry in ~/.local/share/jupyter/kernels (where matlab_kernel went for example) nor in ~/.ipython/kernels nor in /usr/local/share/jupyter/kernels, and so no entry in the 'select kernel' menu item, and "No such kernel error" when I run ipython qtconsole --kernel=xonsh_kernel

Traceback (most recent call last):
  File "/home/louis/anaconda3/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 141, in get_kernel_spec
    resource_dir = d[kernel_name.lower()]
KeyError: 'xonsh_kernel'

During handling of the above exception, another exception occurred:

...

  File "/home/louis/anaconda3/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 143, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: 'xonsh_kernel'

Have I missed something obvious here or is this a work in progress..? Or perhaps not compatible with IPython 4 yet ?

Unable to use IPython.display - '_io.StringIO' object has no attribute 'softspace'

I tried to use the IPython display functionality as below:

from IPython.display import display,HTML
display(HTML('<h4>Here is an H4 header</h4>'))

but I get the following error (on Ubuntu 16.04 and on Windows7, using Anaconda Python).

AttributeError: '_io.StringIO' object has no attribute 'softspace'

Below is my config (on Ubuntu):

mjb@NUC ~ $ xonfig
+------------------+----------+
| xonsh            | 0.3.4    |
| Python           | 3.5.1    |
| PLY              | 3.7      |
| have readline    | True     |
| prompt toolkit   | None     |
| shell type       | readline |
| pygments         | 2.1.1    |
| on posix         | True     |
| on linux         | True     |
| distro           | debian   |
| on darwin        | False    |
| on windows       | False    |
| on cygwin        | False    |
| is superuser     | False    |
| default encoding | utf-8    |
+------------------+----------+

Doesn't work with JupyterLab (statements don't return)

When submitting a command, shell wits forever (with an asterisk) and never returns. Console displays:

[I 13:12:12.296 LabApp] Kernel started: e7b452df-0c35-4a98-b3be-b8b55abbefc9
[I 13:12:13.493 LabApp] Adapting to protocol v5.1 for kernel e7b452df-0c35-4a98-b3be-b8b55abbefc9
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 14820, in default
    run_compiled_code(code, self.ctx, None, 'single')
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 2322, in run_compiled_code
    func(code, glb, loc)
  File "<xonsh-code>", line 1, in <module>
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/ipykernel/displayhook.py", line 34, in __call__
    sys.stdout.flush()
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 14667, in flush
    self.std.flush()
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/tempfile.py", line 848, in flush
    self._file.flush()
ValueError: I/O operation on closed file.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 233, in dispatch_shell
    handler(stream, idents, msg)
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/metakernel/_metakernel.py", line 357, in do_execute
    retval = self.do_execute_direct(code)
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh_kernel/kernel.py", line 45, in do_execute_direct
    out, err, interrupted = self._do_execute_direct(code)
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh_kernel/kernel.py", line 74, in _do_execute_direct
    shell.default(code)
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 14829, in default
    print_exception()
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 4286, in print_exception
    sys.stderr.write('xonsh: For full traceback set: '
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 14663, in write
    self.std.write(std_s)
  File "/home/icarito/Proyectos/Jappy2/.direnv/python-3.5.3/lib/python3.5/tempfile.py", line 905, in write
    rv = file.write(s)
ValueError: I/O operation on closed file.
``

Not working on Windows: "ImportError: cannot import name 'ON_POSIX'"

Running on Windows 7:

  • Python 3.5.1 :: Anaconda 4.0.0 (64-bit)

I installed using

  • pip install xonsh_kernel
    
  • python -m xonsh_kernel.install
    

On starting a notebook from the Jupyter dashboard as "New -> Calysto Xonsh" the kernel dies repeatedly (immediately).

The jupyter console log shows:

[I 19:37:48.022 NotebookApp] Kernel started: 672f7917-b2a4-407a-8e5b-a6e509521df1
Traceback (most recent call last):
File "C:\Progs\Anaconda3\lib\runpy.py", line 170, in run_module_as_main
"main", mod_spec)
File "C:\Progs\Anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Progs\Anaconda3\lib\site-packages\xonsh_kernel__main
.py", line 6, in
from .kernel import XonshKernel
File "C:\Progs\Anaconda3\lib\site-packages\xonsh_kernel\kernel.py", line 10, in
from xonsh.tools import redirect_stdout, redirect_stderr, swap, ON_POSIX
ImportError: cannot import name 'ON_POSIX'

xonsh kernel Module 'builtins' has no attribute __xonsh_shell__

MacOSX, python 3.7, xonsh-0.9.13.dev1, xonsh-kernel-0.4.1, starting jupyter notebook, enter ls, notebook hangs with the following error message displayed in console

/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/ipykernel/iostream.py:14: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  from imp import lock_held as import_lock_held
/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/ipykernel/kernelapp.py:523: DeprecationWarning: zmq.eventloop.ioloop is deprecated in pyzmq 17. pyzmq now works with default tornado and asyncio eventloops.
  zmq_ioloop.install()
/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/jupyter_client/connect.py:401: DeprecationWarning: IPKernelApp._ip_changed is deprecated in traitlets 4.1: use @observe and @unobserve instead.
  def _ip_changed(self, name, old, new):
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
  File "/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 541, in execute_request
    user_expressions, allow_stdin,
  File "/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/metakernel/_metakernel.py", line 395, in do_execute
    retval = self.do_execute_direct(code)
  File "/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/xonsh_kernel/kernel.py", line 45, in do_execute_direct
    out, err, interrupted = self._do_execute_direct(code)
  File "/Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/xonsh_kernel/kernel.py", line 60, in _do_execute_direct
    shell = builtins.__xonsh_shell__
AttributeError: module 'builtins' has no attribute '__xonsh_shell__'
[I 11:20:59.737 NotebookApp] Saving file at /Untitled1.ipynb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.