Git Product home page Git Product logo

bash_kernel's People

Contributors

abbbe avatar bernt-matthias avatar blink1073 avatar costerwi avatar drennalls avatar elibdev avatar herr-biber avatar janpfeifer avatar jeroenjanssens avatar kdm9 avatar montyz avatar mwouts avatar ryukinix avatar sandor-juhasz avatar takluyver avatar triggers avatar xoolive avatar yamaton avatar yuvipanda avatar zimbatm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash_kernel's Issues

Unknown message type displayed when using the bask kernel

OS: Mac OS 10.12.6
jupyter notebook : 5.0.0
bask kernel : latest
browser: Version 59.0.3071.115

Whenever I switched to used the bash kernel, the notebook screen will display the following message, may be we need to know what is the unknown message here.

[I 13:18:57.811 NotebookApp] Serving notebooks from local directory: /Users/sshao
[I 13:18:57.811 NotebookApp] 0 active kernels
[I 13:18:57.811 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=a8232261512b2b7d28e14431035ef212e5ca17a6bf5fa34c
[I 13:18:57.811 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:18:57.814 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    http://localhost:8888/?token=a8232261512b2b7d28e14431035ef212e5ca17a6bf5fa34c

[I 13:18:58.219 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 13:19:10.623 NotebookApp] Kernel started: 8bc0f5f1-4593-4ec7-b5d6-9b783112da99
[IPKernelApp] WARNING | Unknown message type: 'comm_open'
[IPKernelApp] WARNING | Unknown message type: 'comm_open'

installation with pip3 fails: `ImportError: No module named 'IPython.kernel.kernelspec'`

Hi, I'm having trouble installing bash_kernel.

I have downloaded ipython3 via sudo apt-get install ipython3 && sudo apt-get install ipython3-notebook and pip3 via sudo apt-get install python3-pip. Everything worked.

Now, when I run sudo pip3 install bash_kernel, I see:

Downloading/unpacking bash-kernel
  Downloading bash_kernel-0.3.tar.gz
  Running setup.py (path:/tmp/pip_build_root/bash-kernel/setup.py) egg_info for package bash-kernel

Downloading/unpacking pexpect>=3.3 (from bash-kernel)
  Downloading pexpect-3.3.tar.gz (132kB): 132kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pexpect/setup.py) egg_info for package pexpect

Installing collected packages: bash-kernel, pexpect
  Running setup.py install for bash-kernel

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip_build_root/bash-kernel/setup.py", line 53, in <module>
        'Topic :: System :: Shells',
      File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip_build_root/bash-kernel/setup.py", line 20, in run
        from IPython.kernel.kernelspec import install_kernel_spec
    ImportError: No module named 'IPython.kernel.kernelspec'
    Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/bash-kernel/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-bki_y0w5-record/install-
record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib

creating build/lib/bash_kernel

copying bash_kernel/images.py -> build/lib/bash_kernel

copying bash_kernel/__init__.py -> build/lib/bash_kernel

copying bash_kernel/__main__.py -> build/lib/bash_kernel

copying bash_kernel/kernel.py -> build/lib/bash_kernel

running install_lib

creating /usr/local/lib/python3.4

creating /usr/local/lib/python3.4/dist-packages

creating /usr/local/lib/python3.4/dist-packages/bash_kernel

copying build/lib/bash_kernel/images.py -> /usr/local/lib/python3.4/dist-packages/bash_kernel

copying build/lib/bash_kernel/__init__.py -> /usr/local/lib/python3.4/dist-packages/bash_kernel

copying build/lib/bash_kernel/__main__.py -> /usr/local/lib/python3.4/dist-packages/bash_kernel

copying build/lib/bash_kernel/kernel.py -> /usr/local/lib/python3.4/dist-packages/bash_kernel

byte-compiling /usr/local/lib/python3.4/dist-packages/bash_kernel/images.py to images.cpython-34.pyc

byte-compiling /usr/local/lib/python3.4/dist-packages/bash_kernel/__init__.py to __init__.cpython-34.pyc

byte-compiling /usr/local/lib/python3.4/dist-packages/bash_kernel/__main__.py to __main__.cpython-34.pyc

byte-compiling /usr/local/lib/python3.4/dist-packages/bash_kernel/kernel.py to kernel.cpython-34.pyc

running install_egg_info

running egg_info

creating bash_kernel.egg-info

writing dependency_links to bash_kernel.egg-info/dependency_links.txt

writing bash_kernel.egg-info/PKG-INFO

writing requirements to bash_kernel.egg-info/requires.txt

writing top-level names to bash_kernel.egg-info/top_level.txt

writing manifest file 'bash_kernel.egg-info/SOURCES.txt'

warning: manifest_maker: standard file '-c' not found



reading manifest file 'bash_kernel.egg-info/SOURCES.txt'

writing manifest file 'bash_kernel.egg-info/SOURCES.txt'

Copying bash_kernel.egg-info to /usr/local/lib/python3.4/dist-packages/bash_kernel-0.3.egg-info

writing list of installed files to '/tmp/pip-bki_y0w5-record/install-record.txt'

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/tmp/pip_build_root/bash-kernel/setup.py", line 53, in <module>

    'Topic :: System :: Shells',

  File "/usr/lib/python3.4/distutils/core.py", line 148, in setup

    dist.run_commands()

  File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands

    self.run_command(cmd)

  File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command

    cmd_obj.run()

  File "/tmp/pip_build_root/bash-kernel/setup.py", line 20, in run

    from IPython.kernel.kernelspec import install_kernel_spec

ImportError: No module named 'IPython.kernel.kernelspec'

----------------------------------------
Cleaning up...

Thanks for your help! I'm excited to try this! (And thanks @jeroenjanssens for the very cool article; it brought me here!)

Installation fails when installing on systems without root access

(ipython3)[chiakhb@n069 CAMI]$ pip install bash_kernel
You are using pip version 6.0.8, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting bash-kernel
Using cached bash_kernel-0.3.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pexpect>=3.3 in /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages (from bash-kernel)
Installing collected packages: bash-kernel
Running setup.py install for bash-kernel
Installing IPython kernel spec
error: [Errno 13] Permission denied: '/usr/local/share/jupyter'
Complete output from command /mnt/software/unstowable/anaconda/envs/ipython3/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-KkZeU0/bash-kernel/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-aMy_O4-record/install-record.txt --single-version-externally-managed --compile:
running install

running build

running build_py

creating build

creating build/lib

creating build/lib/bash_kernel

copying bash_kernel/__init__.py -> build/lib/bash_kernel

copying bash_kernel/images.py -> build/lib/bash_kernel

copying bash_kernel/__main__.py -> build/lib/bash_kernel

copying bash_kernel/kernel.py -> build/lib/bash_kernel

running install_lib

creating /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel

copying build/lib/bash_kernel/__init__.py -> /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel

copying build/lib/bash_kernel/images.py -> /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel

copying build/lib/bash_kernel/__main__.py -> /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel

copying build/lib/bash_kernel/kernel.py -> /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel

byte-compiling /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel/__init__.py to __init__.pyc

byte-compiling /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel/images.py to images.pyc

byte-compiling /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel/__main__.py to __main__.pyc

byte-compiling /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel/kernel.py to kernel.pyc

running install_egg_info

running egg_info

creating bash_kernel.egg-info

writing requirements to bash_kernel.egg-info/requires.txt

writing bash_kernel.egg-info/PKG-INFO

writing top-level names to bash_kernel.egg-info/top_level.txt

writing dependency_links to bash_kernel.egg-info/dependency_links.txt

writing manifest file 'bash_kernel.egg-info/SOURCES.txt'

warning: manifest_maker: standard file '-c' not found



reading manifest file 'bash_kernel.egg-info/SOURCES.txt'

writing manifest file 'bash_kernel.egg-info/SOURCES.txt'

Copying bash_kernel.egg-info to /mnt/software/unstowable/anaconda/envs/ipython3/lib/python2.7/site-packages/bash_kernel-0.3-py2.7.egg-info

writing list of installed files to '/tmp/pip-aMy_O4-record/install-record.txt'

Installing IPython kernel spec

error: [Errno 13] Permission denied: '/usr/local/share/jupyter'

----------------------------------------
Command "/mnt/software/unstowable/anaconda/envs/ipython3/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-KkZeU0/bash-kernel/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-aMy_O4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-KkZeU0/bash-kernel

Deprecation warning on install...

Got this when I install against jupyter 4.x:

(python34)BrianTempRetinaMBP:.ipython bgranger$ python -m bash_kernel.install
/Users/bgranger/anaconda/envs/python34/lib/python3.5/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
Installing IPython kernel spec

Just needs to be updated to use the new API.

%load and %run Not Working

When I try:

%run TEST_Bash_Script.sh

it returns:

bash: fg: %run: no such job

I'm not sure if the %run and %load cell magic is supposed to be available with the bash_kernel, but even if it isn't, it would be very nice to have. Thanks!

%%HTML magic doesn't work under bash kernel

Not sure if this is a bug or not, seeking clarification. Under Python notebooks, we can put arbitrary HTML in a cell with the %%HTML magic:

%%HTML
<style>
div {
    background-color: red;
}
</style>

which I normally use for styling notebooks for giving talks. This doesn't work under the bash kernel. Do any of the jupyter magics work with this kernel? Should they? and if not, is there some other way to go about styling the notebook? I've played around with various custom.css files in different locations but can't get anything to work.

Cell execution failure does not cause nbconvert --execute to fail as expected

When executing a notebook using nbconvert by default failing code cells will result in the notebook execution to fail. However this doesn't happen for bash_kernel-based notebooks. Below is an example of a notebook with a failing code cell that has "ls sdsdsd". The exitcode is being checked in kernel.py (in BashKernel.do_execute) however it's only sending the error as the return value but not as a response which it seems nbconvert needs.

...e.g. bash notebook with a failing code cell..

[drennalls@drennalls-dev jupyter]$ cat FailingBashNotebook.ipynb
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "ls sdsd\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Bash",
   "language": "bash",
   "name": "bash"
  },
  "language_info": {
   "codemirror_mode": "shell",
   "file_extension": ".sh",
   "mimetype": "text/x-sh",
   "name": "bash"
  },
  "toc": {
   "toc_cell": false,
   "toc_number_sections": true,
   "toc_threshold": 4,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}

Executing...

jupyter nbconvert --execute --to notebook --inplace FailingBashNotebook.ipynb

...should fail, but it doesn't

please tag the 0.5 release

on pypi there's a version 0.5 of bash_kernel, but there is no corresponding tag here in the repo. It would be nice if you could add this.

weird outputs from repeatedly calling `env`

When I use the command env to look at what environment variables exist, I get 1 of 3 answers, depending on how many times I run the env command... The first time I get a reasonable output, the second time I get a value of 0, and the third time I get yet a different output. Any idea why this happens? Looks like a bug to me... I have pasted the code and output below:

env

TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/ct/x1hy892j365bfhpjfrm265qm0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.hTRcxjkG4D/Render
PERL5LIB=/usr/local/lib/perl5/site_perl:
TERM_PROGRAM_VERSION=343.7
TERM_SESSION_ID=C73FB697-9099-450E-B537-2786A7CD2543
USER=tiffanytimbers
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.vJ6R1ZtODG/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
JPY_PARENT_PID=7620
PAGER=cat
PATH=//anaconda/bin:/opt/local/bin:/opt/local/sbin:/Users/tiffanytimbers/Documents/Post-Doc/GWAS/vcftools_0.1.12b/perl:/usr/local/Cellar/vcftools/0.1.12b-2/bin:/Users/tiffanytimbers/bin/plink_mac:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin
PWD=/Users/tiffanytimbers/Documents/MDS-UBC/DSCI_521_platforms-dsci/lectures
LANG=en_CA.UTF-8
XPC_FLAGS=0x0
PS1=
env

0
env

XPC_SERVICE_NAME=0
HOME=/Users/tiffanytimbers
SHLVL=2
LOGNAME=tiffanytimbers
DISPLAY=/private/tmp/com.apple.launchd.U7ULVI89iY/org.macosforge.xquartz:0
_=/usr/bin/env

Kernel is installing into user location when run as root

Hello ๐Ÿ‘‹

I think #65 introduced an issue where the kernel always installs into the users home directory, even when running as root or providing the --prefix argument.

I'm not too familiar with argparse, but it looks like the actions line is setting the user flag to True, even if _is_root returns True.

Reproduce:

  • Run sudo python3 -m bash_kernel.install or sudo python3 -m bash_kernel.install --prefix /usr/local

Expected:

  • Kernel installed to /usr/local/share/jupyter/kernels/

Actual

  • Kernel installed to /root/.local/share/jupyter/kernels/

Error when installing in OSX

Regardless of the method; i.e., using pip install bash_kernel or downloading a snapshot from Github and manually launching python setup.py install I get the following error:

running install
running build
running build_py
creating build
creating build/lib
creating build/lib/bash_kernel
copying bash_kernel/__init__.py -> build/lib/bash_kernel
copying bash_kernel/__main__.py -> build/lib/bash_kernel
copying bash_kernel/images.py -> build/lib/bash_kernel
copying bash_kernel/kernel.py -> build/lib/bash_kernel
running install_lib
running install_egg_info
removing '/Users/ajmazurie/.pyenv/versions/_jupyter/lib/python2.7/site-packages/bash_kernel-0.3-py2.7.egg-info' (and everything under it)
Writing /Users/ajmazurie/.pyenv/versions/_jupyter/lib/python2.7/site-packages/bash_kernel-0.3-py2.7.egg-info
Installing IPython kernel spec
error: [Errno 13] Permission denied: '/usr/local/share/jupyter'

It appears that the installation process expects a hardcoded folder /usr/local/share/jupyter/, which is not installed by Jupyter (at least not on my Mac). I'm using OSX 10.10.3 and Jupyter 3.2.1

Best,
Aurelien

Kernel not working with Jupyter 4.4 and Python 3.6

I installed a fresh copy of the bash kernel, and it fails with the following exception:

[I 15:11:00.455 NotebookApp] Kernel started: 79d44efe-a83a-4da9-a6b2-c23dba9af3f5
[W 15:11:12.141 NotebookApp] Timeout waiting for kernel_info reply from 79d44efe-a83a-4da9-a6b2-c23dba9af3f5
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pexpect/expect.py", line 98, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/usr/local/lib/python3.6/dist-packages/pexpect/pty_spawn.py", line 466, in read_nonblocking
    raise TIMEOUT('Timeout exceeded.')
pexpect.exceptions.TIMEOUT: Timeout exceeded. 

Thanks in advance if you can try to solve this. I can help by providing error messages if needed.

pexpect Unicode issue prevents kernel startup

I'm unable to start a Bash kernel with the latest version--as soon as I enter code in Jupyter, I get an exception like this:

[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 228, in dispatch_shell
    handler(stream, idents, msg)
  File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 390, in execute_request
    user_expressions, allow_stdin)
  File "/usr/local/lib/python2.7/dist-packages/bash_kernel/kernel.py", line 147, in do_execute
    self.bashwrapper.run_command(str(code.rstrip()), timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/pexpect/replwrap.py", line 95, in run_command
    if self._expect_prompt(timeout=timeout) == 1:
  File "/usr/local/lib/python2.7/dist-packages/bash_kernel/kernel.py", line 44, in _expect_prompt
    timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 383, in expect_exact
    pattern_list = [prepare_pattern(p) for p in pattern_list]
  File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 377, in prepare_pattern
    self._pattern_type_err(pattern)
  File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 172, in _pattern_type_err
    for ast in self.allowed_string_types])
TypeError: got <type 'str'> ('\r\n') as pattern, must be one of: <type 'unicode'>, pexpect.EOF, pexpect.TIMEOUT

It seems there's some kind of string issue going on with pexpect

.bashrc Seems to Cause the Kernel not to Work

I have the following in my .bashrc:

\# .bashrc

\# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

\# User specific aliases and functions
I have a bunch of straightforward aliases, but I don't think they are causing the problem. They are all either database calls or things like rm='rm -i'. We suspect that the color changes in my prompt are the problem. 

#export PS1="[jlatto@Winterfell:\w $(date)]> "

#export PS1="[\t] \[\033[1;33m\]\u\[\033[0m\]@\h:\[\033[36m\][\w]:\[\033[0m\]> "
export PS1="[\t] \[\033[1;35m\] \u\[\033[0m\]@R\[\033[36m\] [\w]\[\033[0m\]> "
#export PS1="[\e]2;\w\a\e[31;40;1m]----------------------------------------------------------------------------------------------------------------------------------------------------------------\n)[\e[0m] ";

When I run the notebook server and open up a notebook with the Bash Kernel, nothing will run. If I comment out everything, and then relaunch the server it works fine. Please let me know if there is other information that would be useful. Thanks for looking into this!

ImportError: No module named kernelspec

Hi, I'm trying to install the bash_kernel on my local machine and I'm getting this error message:

chiakhb@localhost bash_kernel-master]$ sudo python setup.py install
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running install
running build
running build_py
running install_lib
running install_egg_info
Removing /usr/lib/python2.7/site-packages/bash_kernel-0.3-py2.7.egg-info
Writing /usr/lib/python2.7/site-packages/bash_kernel-0.3-py2.7.egg-info
Traceback (most recent call last):
File "setup.py", line 54, in
'Topic :: System :: Shells',
File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "setup.py", line 21, in run
from IPython.kernel.kernelspec import install_kernel_spec
ImportError: No module named kernelspec

Executing man in a code cell causes unexpected output

Running the man command in a code cell causes some, but not all, characters to be repeated in the output:

selection_016

Copying and pasting the output into a text editor reveals that it actually contains a bunch of backspace characters:

selection_017

I have absolutely no idea what's going on here - is it maybe something to do with the output from man going through a pager before being displayed in jupyter? I'm using bash notebooks for teaching purposes, so it would be good to be able to illustrate the man command.

Can't install dev version

Right now there are fixes in master of bash_kernel that I need. But, because:

  1. There is no setup.py in the repo.
  2. A release hasn't been made since August.

I am unable to install this using pip and github URLs. I am automating a JupyterHub deployment using ansible and not being able to install with pip directly from GitHub gets to be really painful.

I am all for using things like flit to ease development and maintenance, but not being able to install from source with pip is a huge annoyance. Options:

  • Release more often (even minor versions).
  • Use flit to autogenerate a setup.py that is checked into the repo.

Thoughts?

Kernel crashes repetedly if $PS1 does not end in $

I was using a powerline like shell prompt and tried using the bash kernel. It repeatedly crashed, showing a traceback in the logs that led me to believe you were looking for a prompt that ended in "$"

Traceback (most recent call last):
  File "/home/user/env/lib64/python3.5/site-packages/pexpect/expect.py", line 98, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/home/user/env/lib64/python3.5/site-packages/pexpect/pty_spawn.py", line 466, in read_nonblocking
    raise TIMEOUT('Timeout exceeded.')
pexpect.exceptions.TIMEOUT: Timeout exceeded.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/elijah/envs/chkt/lib64/python3.5/site-packages/bash_kernel/__main__.py", line 3, in <module>
    IPKernelApp.launch_instance(kernel_class=BashKernel)
  File "/home/user/env/lib64/python3.5/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-123>", line 2, in initialize
  File "/home/user/env/lib64/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/user/env/lib64/python3.5/site-packages/ipykernel/kernelapp.py", line 457, in initialize
    self.init_kernel()
  File "/home/user/env/lib64/python3.5/site-packages/ipykernel/kernelapp.py", line 368, in init_kernel
    user_ns=self.user_ns,
  File "/home/user/env/lib64/python3.5/site-packages/traitlets/config/configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "/home/user/envlib64/python3.5/site-packages/bash_kernel/kernel.py", line 81, in __init__
    self._start_bash()
  File "/home/user/env/lib64/python3.5/site-packages/bash_kernel/kernel.py", line 104, in _start_bash
    line_output_callback=self.process_output)
  File "/home/user/envlib64/python3.5/site-packages/bash_kernel/kernel.py", line 33, in __init__
    prompt_change, extra_init_cmd=extra_init_cmd)
  File "/home/user/env/lib64/python3.5/site-packages/pexpect/replwrap.py", line 51, in __init__
    prompt_change.format(new_prompt, continuation_prompt))
  File "/home/elijah/envs/chkt/lib64/python3.5/site-packages/pexpect/replwrap.py", line 61, in set_prompt
    self.child.expect(orig_prompt)
  File "/home/user/env/lib64/python3.5/site-packages/pexpect/spawnbase.py", line 327, in expect
    timeout, searchwindowsize, async_)
  File "/home/user/env/lib64/python3.5/site-packages/pexpect/spawnbase.py", line 355, in expect_list
    return exp.expect_loop(timeout)
  File "/home/user/env/lib64/python3.5/site-packages/pexpect/expect.py", line 106, in expect_loop
    return self.timeout(e)
  File "/home/user/envlib64/python3.5/site-packages/pexpect/expect.py", line 70, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7ff254664240>
command: /usr/bin/bash
args: [b'/usr/bin/bash', b'--rcfile', b'/home/user/env/lib64/python3.5/site-packages/pexpect/bashrc.sh']
buffer (last 100 chars): '5;250;48;5;240msfw\xa0\x1b[0;38;5;245;48;5;240;22m\ue0b1\xa0\x1b[0;38;5;252;48;5;240;1mchkt\xa0\x1b[0;38;5;240;49;22m\ue0b0\xa0\x1b[0m'
before (last 100 chars): '5;250;48;5;240msfw\xa0\x1b[0;38;5;245;48;5;240;22m\ue0b1\xa0\x1b[0;38;5;252;48;5;240;1mchkt\xa0\x1b[0;38;5;240;49;22m\ue0b0\xa0\x1b[0m'
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 28695
child_fd: 46
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile("\$")

It started working once I disabled my powerline by commenting out the part of my .bashrc that makes me use thep powerline and putting a more "traditional" PS1 prompt in there. i.e. export PS1="$USER@$HOSTNAME:${PWD} \$ "

Ideally, I'd like not to have to do this to use this plugin, which I really like the idea of!

I took a quick look and it was not immediately obvious how this regex is getting formed because it is not verbatim in the code. If you have tips on how it gets made, I would make a PR to fix this.

Can't use docker run / docker attach

If I run a docker container or attach, the ipython notebook just hangs until the container is stopped.

docker run -i -t centos:centos6 /bin/bash

or

docker run -d -i -t centos:centos6 /bin/bash
docker attach [CONTAINER_ID]

I'm not sure if it would be possible to attach to the docker container and treat that as a single command, so I can show commands that are ran inside the container as the notebook progresses.

Some basic magics are needed

I plan to use Jupyter + bash_kernel for tutorials, I find it extremely useful to build up a narrative with command-line operations like that.

It's unfortunate that no cell magics are available.

In particular, I'd like to find a way of initializing a file in a code cell which looks natural to a reader
(so although it's executeable code, it looks natural as if I'd just shown the contents in a Markdown cell).

For now I do a HERE document, as below, but this looks rather clunky and could confuse people.

cat > textfile <<EOF
line1
line2
EOF

A better way would be to have a %writefile/%readfile magic as IPython has, so I could have a Code cell like

%writefile textfile
line1
line2

Unless you have a better suggestion ...

A slightly nicer way

Attribute error: module 'pexpect' has no attribute spawn

I am encountering this error when attempting to execute bash commands or restarting a bash kernel. See snip below. The pexpect module version is 4.2.1. Python version is 3.6.1 64 bit. Feedback on this would be helpful. Thanks.

image

Timeout upon starting

Hello

I tried to install your bash_kernel but got a timeout upon starting it.
You will find the traceback here under.

Of course trying any command doesn't get me anything...

Could you have a look?

[I 22:09:01.090 NotebookApp] Kernel started: 295e0a2f-7ef2-447a-942b-2ebb130bd663
[W 22:09:11.431 NotebookApp] Timeout waiting for kernel_info reply from 295e0a2f-7ef2-447a-942b-2ebb130bd663
---------------------------------------------------------------------------
TIMEOUT                                   Traceback (most recent call last)
/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/__init__.py in expect_loop(self=<pexpect.spawnu object>, searcher=<pexpect.searcher_re object>, timeout=29.990046977996826, searchwindowsize=None)
   1534                 # Still have time left, so read more data
-> 1535                 c = self.read_nonblocking(self.maxread, timeout)
        c = '%{\x1b[1;32m%}%n%{\x1b[0m%} at %{\x1b[1;31m%}%m%{\x1b[0m%} in %{\x1b[1;35m%}%~%{\x1b[0m%} '
        self.read_nonblocking = <bound method spawnu.read_nonblocking of <pexpect.spawnu object at 0x108320e10>>
        self.maxread = 2000
        timeout = 29.990046977996826
   1536                 freshlen = len(c)

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/__init__.py in read_nonblocking(self=<pexpect.spawnu object>, size=2000, timeout=29.990046977996826)
    967             else:
--> 968                 raise TIMEOUT('Timeout exceeded.')
        global TIMEOUT = <class 'pexpect.TIMEOUT'>
    969 

TIMEOUT: Timeout exceeded.

During handling of the above exception, another exception occurred:

TIMEOUT                                   Traceback (most recent call last)
/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py in _run_module_as_main(mod_name='bash_kernel.__main__', alter_argv=1)
    168         sys.argv[0] = mod_spec.origin
    169     return _run_code(code, main_globals, None,
--> 170                      "__main__", mod_spec)
        mod_spec = ModuleSpec(name='bash_kernel.__main__', loader=<_frozen_importlib.SourceFileLoader object at 0x10739a4e0>, origin='/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/__main__.py')
    171 
    172 def run_module(mod_name, init_globals=None,

/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py in _run_code(code=<code object <module> at 0x10737d0c0, file "/Use...4/site-packages/bash_kernel/__main__.py", line 1>, run_globals={'BashKernel': <class 'bash_kernel.kernel.BashKernel'>, 'IPKernelApp': <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, '__builtins__': <module 'builtins' (built-in)>, '__cached__': '/Users/xo/Library/virtualenv/python34/lib/python...s/bash_kernel/__pycache__/__main__.cpython-34.pyc', '__doc__': None, '__file__': '/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/__main__.py', '__loader__': <_frozen_importlib.SourceFileLoader object>, '__name__': '__main__', '__package__': 'bash_kernel', '__spec__': ModuleSpec(name='bash_kernel.__main__', loader=<...python3.4/site-packages/bash_kernel/__main__.py')}, init_globals=None, mod_name='__main__', mod_spec=ModuleSpec(name='bash_kernel.__main__', loader=<...python3.4/site-packages/bash_kernel/__main__.py'), pkg_name='bash_kernel', script_name=None)
     83                        __package__ = pkg_name,
     84                        __spec__ = mod_spec)
---> 85     exec(code, run_globals)
        global exec = undefined
        code = <code object <module> at 0x10737d0c0, file "/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/__main__.py", line 1>
        run_globals = {'__doc__': None, '__spec__': ModuleSpec(name='bash_kernel.__main__', loader=<_frozen_importlib.SourceFileLoader object at 0x10739a4e0>, origin='/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/__main__.py'), '__cached__': '/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/__pycache__/__main__.cpython-34.pyc', '__name__': '__main__', '__package__': 'bash_kernel', 'IPKernelApp': <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, '__loader__': <_frozen_importlib.SourceFileLoader object at 0x10739a4e0>, '__builtins__': <module 'builtins' (built-in)>, 'BashKernel': <class 'bash_kernel.kernel.BashKernel'>, '__file__': '/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/__main__.py'}
     86     return run_globals
     87 

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/__main__.py in <module>()
      1 from IPython.kernel.zmq.kernelapp import IPKernelApp
      2 from .kernel import BashKernel
----> 3 IPKernelApp.launch_instance(kernel_class=BashKernel)
        global IPKernelApp.launch_instance = <bound method MetaHasTraits.launch_instance of <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>>
        global kernel_class = undefined
        global BashKernel = <class 'bash_kernel.kernel.BashKernel'>

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/IPython/config/application.py in launch_instance(cls=<class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, argv=None, **kwargs={'kernel_class': <class 'bash_kernel.kernel.BashKernel'>})
    571         """
    572         app = cls.instance(**kwargs)
--> 573         app.initialize(argv)
        app.initialize = <bound method IPKernelApp.initialize of <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x107253cf8>>
        argv = None
    574         app.start()
    575 

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/IPython/kernel/zmq/kernelapp.py in initialize(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, argv=None)

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/IPython/config/application.py in catch_config_error(method=<function IPKernelApp.initialize>, app=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, *args=(None,), **kwargs={})
     73     """
     74     try:
---> 75         return method(app, *args, **kwargs)
        method = <function IPKernelApp.initialize at 0x1081f20d0>
        app = <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x107253cf8>
        args = (None,)
        kwargs = {}
     76     except (TraitError, ArgumentError) as e:
     77         app.print_help()

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/IPython/kernel/zmq/kernelapp.py in initialize(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, argv=None)
    354         self.init_io()
    355         self.init_signal()
--> 356         self.init_kernel()
        self.init_kernel = <bound method IPKernelApp.init_kernel of <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x107253cf8>>
    357         # shell init steps
    358         self.init_path()

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/IPython/kernel/zmq/kernelapp.py in init_kernel(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>)
    308                                 log=self.log,
    309                                 profile_dir=self.profile_dir,
--> 310                                 user_ns=self.user_ns,
        global user_ns = undefined
        self.user_ns = None
    311         )
    312         kernel.record_ports(self.ports)

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/IPython/config/configurable.py in instance(cls=<class 'bash_kernel.kernel.BashKernel'>, *args=(), **kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <IPython.kernel.zmq.session.Session object>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object>, <zmq.eventloop.zmqstream.ZMQStream object>], 'stdin_socket': <zmq.sugar.socket.Socket object>, 'user_ns': None})
    335         # Create and save the instance
    336         if cls._instance is None:
--> 337             inst = cls(*args, **kwargs)
        inst = undefined
        cls = <class 'bash_kernel.kernel.BashKernel'>
        args = ()
        kwargs = {'log': <logging.Logger object at 0x1072fcc88>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object at 0x108320a20>, <zmq.eventloop.zmqstream.ZMQStream object at 0x108320c88>], 'stdin_socket': <zmq.sugar.socket.Socket object at 0x10822af48>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x107253cf8>, 'profile_dir': <IPython.core.profiledir.ProfileDir object at 0x1082074e0>, 'user_ns': None, 'iopub_socket': <zmq.sugar.socket.Socket object at 0x10822a588>, 'session': <IPython.kernel.zmq.session.Session object at 0x108207d68>}
    338             # Now make sure that the instance will also be returned by
    339             # parent classes' _instance attribute.

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/kernel.py in __init__(self=<bash_kernel.kernel.BashKernel object>, **kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <IPython.kernel.zmq.session.Session object>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object>, <zmq.eventloop.zmqstream.ZMQStream object>], 'stdin_socket': <zmq.sugar.socket.Socket object>, 'user_ns': None})
     44     def __init__(self, **kwargs):
     45         Kernel.__init__(self, **kwargs)
---> 46         self._start_bash()
        self._start_bash = <bound method BashKernel._start_bash of <bash_kernel.kernel.BashKernel object at 0x108320dd8>>
     47 
     48     def _start_bash(self):

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/bash_kernel/kernel.py in _start_bash(self=<bash_kernel.kernel.BashKernel object>)
     53         sig = signal.signal(signal.SIGINT, signal.SIG_DFL)
     54         try:
---> 55             self.bashwrapper = replwrap.bash()
        self.bashwrapper = undefined
        global replwrap.bash = <function bash at 0x1081f28c8>
     56         finally:
     57             signal.signal(signal.SIGINT, sig)

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/replwrap.py in bash(command='bash', orig_prompt=re.compile('[$#]'))
    101 def bash(command="bash", orig_prompt=re.compile('[$#]')):
    102     """Start a bash shell and return a :class:`REPLWrapper` object."""
--> 103     return REPLWrapper(command, orig_prompt, u("PS1='{0}' PS2='{1}' PROMPT_COMMAND=''"))
        global REPLWrapper = <class 'pexpect.replwrap.REPLWrapper'>
        command = 'bash'
        orig_prompt = re.compile('[$#]')
        global u = <function u at 0x1081f2598>

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/replwrap.py in __init__(self=<pexpect.replwrap.REPLWrapper object>, cmd_or_spawn='bash', orig_prompt=re.compile('[$#]'), prompt_change="PS1='{0}' PS2='{1}' PROMPT_COMMAND=''", new_prompt='[PEXPECT_PROMPT>', continuation_prompt='[PEXPECT_PROMPT+')
     48         else:
     49             self.set_prompt(orig_prompt,
---> 50                         prompt_change.format(new_prompt, continuation_prompt))
        prompt_change.format = <built-in method format of str object at 0x1081e7240>
        new_prompt = '[PEXPECT_PROMPT>'
        continuation_prompt = '[PEXPECT_PROMPT+'
     51             self.prompt = new_prompt
     52         self.continuation_prompt = continuation_prompt

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/replwrap.py in set_prompt(self=<pexpect.replwrap.REPLWrapper object>, orig_prompt=re.compile('[$#]'), prompt_change="PS1='[PEXPECT_PROMPT>' PS2='[PEXPECT_PROMPT+' PROMPT_COMMAND=''")
     55 
     56     def set_prompt(self, orig_prompt, prompt_change):
---> 57         self.child.expect(orig_prompt)
        self.child.expect = <bound method spawnu.expect of <pexpect.spawnu object at 0x108320e10>>
        orig_prompt = re.compile('[$#]')
     58         self.child.sendline(prompt_change)
     59 

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/__init__.py in expect(self=<pexpect.spawnu object>, pattern=re.compile('[$#]'), timeout=-1, searchwindowsize=-1)
   1449         compiled_pattern_list = self.compile_pattern_list(pattern)
   1450         return self.expect_list(compiled_pattern_list,
-> 1451                 timeout, searchwindowsize)
        timeout = -1
        searchwindowsize = -1
   1452 
   1453     def expect_list(self, pattern_list, timeout=-1, searchwindowsize=-1):

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/__init__.py in expect_list(self=<pexpect.spawnu object>, pattern_list=[re.compile('[$#]')], timeout=-1, searchwindowsize=-1)
   1464 
   1465         return self.expect_loop(searcher_re(pattern_list),
-> 1466                 timeout, searchwindowsize)
        timeout = -1
        searchwindowsize = -1
   1467 
   1468     def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1):

/Users/xo/Library/virtualenv/python34/lib/python3.4/site-packages/pexpect/__init__.py in expect_loop(self=<pexpect.spawnu object>, searcher=<pexpect.searcher_re object>, timeout=29.990046977996826, searchwindowsize=None)
   1566                 self.match = None
   1567                 self.match_index = None
-> 1568                 raise TIMEOUT(str(err) + '\n' + str(self))
        global TIMEOUT = <class 'pexpect.TIMEOUT'>
        global str = undefined
        err = TIMEOUT('Timeout exceeded.',)
        self = <pexpect.spawnu object at 0x108320e10>
   1569         except:
   1570             self.before = incoming

TIMEOUT: Timeout exceeded.
<pexpect.spawnu object at 0x108320e10>
version: 3.3
command: /bin/bash
args: ['/bin/bash']
searcher: <pexpect.searcher_re object at 0x108320f28>
buffer (last 100 chars): '%{\x1b[1;32m%}%n%{\x1b[0m%} at %{\x1b[1;31m%}%m%{\x1b[0m%} in %{\x1b[1;35m%}%~%{\x1b[0m%} '
before (last 100 chars): '%{\x1b[1;32m%}%n%{\x1b[0m%} at %{\x1b[1;31m%}%m%{\x1b[0m%} in %{\x1b[1;35m%}%~%{\x1b[0m%} '
after: <class 'pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 35468
child_fd: 44
closed: False
timeout: 30
delimiter: <class '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

kernel hangs when output has invalid unicode

This is of interest because badly-behaved applications can create files with invalid names.

Try the following python script to create 1 good file and 2 files with bad unicode name in folder "BAD":

fnlist = [
    b"BAD/good.txt",
    b"BAD/\xe1",
    b"BAD/\xfe\xfe\xff\xff"
]

for i,fn in enumerate(fnlist):
    with open(fn,"w") as outf:
        outf.write("Hello {}\n".format(i))

Then open a jupyter client with bash_kernel and the following will cause the client to stall waiting on output from the kernel:

echo BAD/*

Kernel did not respond: pexpect.exceptions.TIMEOUT

Dead kernel in jupyter.
Python 3.5.2 | Anaconda 4.1.1 (64-bit) | pexpect 4.0.1

jupyter-console gives pexpect.exceptions.TIMEOUT error.
Any advice would be appreciated.

root@LA1:~# jupyter-console   --kernel='Bash'  --debug
[ZMQTerminalIPythonApp] Searching ['/root', '/root/.jupyter', '/root/anaconda3/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[ZMQTerminalIPythonApp] Looking for jupyter_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /usr/local/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /root/anaconda3/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /root/.jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /root
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /usr/local/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /root/anaconda3/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /root/.jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /root
[ZMQTerminalIPythonApp] Connection File not found: /root/.local/share/jupyter/runtime/kernel-21653.json
[ZMQTerminalIPythonApp] Found kernel bash in /usr/local/share/jupyter/kernels
[ZMQTerminalIPythonApp] Native kernel (python3) available from /root/anaconda3/lib/python3.5/site-packages/ipykernel/resources
[ZMQTerminalIPythonApp] Starting kernel: ['/root/anaconda3/envs/py35/bin/python', '-m', 'bash_kernel', '-f', '/root/.local/share/jupyter/runtime/kernel-21653.json']
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:59447
[ZMQTerminalIPythonApp] connecting shell channel to tcp://127.0.0.1:47610
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:47610
[ZMQTerminalIPythonApp] connecting iopub channel to tcp://127.0.0.1:35024
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:35024
[ZMQTerminalIPythonApp] connecting stdin channel to tcp://127.0.0.1:40135
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:40135
[ZMQTerminalIPythonApp] connecting heartbeat channel to tcp://127.0.0.1:42427
Jupyter Console 4.1.1

[ZMQTerminalIPythonApp] Starting the jupyter console mainloop...
Traceback (most recent call last):
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/expect.py", line 97, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/pty_spawn.py", line 452, in read_nonblocking
    raise TIMEOUT('Timeout exceeded.')
pexpect.exceptions.TIMEOUT: Timeout exceeded.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/anaconda3/envs/py35/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/root/anaconda3/envs/py35/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/bash_kernel/__main__.py", line 3, in <module>
    IPKernelApp.launch_instance(kernel_class=BashKernel)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/traitlets/config/application.py", line 595, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-122>", line 2, in initialize
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 421, in initialize
    self.init_kernel()
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 360, in init_kernel
    user_ns=self.user_ns,
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/traitlets/config/configurable.py", line 405, in instance
    inst = cls(*args, **kwargs)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/bash_kernel/kernel.py", line 46, in __init__
    self._start_bash()
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/bash_kernel/kernel.py", line 55, in _start_bash
    self.bashwrapper = replwrap.bash()
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/replwrap.py", line 113, in bash
    extra_init_cmd="export PAGER=cat")
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/replwrap.py", line 51, in __init__
    prompt_change.format(new_prompt, continuation_prompt))
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/replwrap.py", line 61, in set_prompt
    self.child.expect(orig_prompt)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/spawnbase.py", line 315, in expect
    timeout, searchwindowsize, async)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/spawnbase.py", line 339, in expect_list
    return exp.expect_loop(timeout)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/expect.py", line 104, in expect_loop
    return self.timeout(e)
  File "/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/expect.py", line 68, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7f30cee93a58>
command: /bin/bash
args: ['/bin/bash', '--rcfile', '/root/anaconda3/envs/py35/lib/python3.5/site-packages/pexpect/bashrc.sh']
searcher: None
buffer (last 100 chars): 'root@LA1:~# '
before (last 100 chars): 'root@LA1:~# '
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 21668
child_fd: 45
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
ERROR: Kernel did not respond

Shutting down kernel

Here is the working default python kernel:

root@LA1:~# jupyter-console   --debug
[ZMQTerminalIPythonApp] Searching ['/root', '/root/.jupyter', '/root/anaconda3/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[ZMQTerminalIPythonApp] Looking for jupyter_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /usr/local/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /root/anaconda3/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /root/.jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /root
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /usr/local/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /root/anaconda3/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /root/.jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /root
[ZMQTerminalIPythonApp] Connection File not found: /root/.local/share/jupyter/runtime/kernel-21723.json
[ZMQTerminalIPythonApp] Found kernel bash in /usr/local/share/jupyter/kernels
[ZMQTerminalIPythonApp] Native kernel (python3) available from /root/anaconda3/lib/python3.5/site-packages/ipykernel/resources
[ZMQTerminalIPythonApp] Starting kernel: ['/root/anaconda3/bin/python', '-m', 'ipykernel', '-f', '/root/.local/share/jupyter/runtime/kernel-21723.json']
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:35255
[ZMQTerminalIPythonApp] connecting shell channel to tcp://127.0.0.1:51449
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:51449
[ZMQTerminalIPythonApp] connecting iopub channel to tcp://127.0.0.1:53805
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:53805
[ZMQTerminalIPythonApp] connecting stdin channel to tcp://127.0.0.1:60247
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:60247
[ZMQTerminalIPythonApp] connecting heartbeat channel to tcp://127.0.0.1:52567
Jupyter Console 4.1.1

[ZMQTerminalIPythonApp] Starting the jupyter console mainloop...

In [1]: import sys

In [2]: sys.version
Out[2]: '3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul  2 2016, 17:53:06) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]'

In [3]: import pexpect

In [4]: pexpect.__version__
Out[4]: '4.0.1'

Interrupting code doesn't work

If you do sleep 10, and then press ctrl-c to interrupt it, nothing happens. Press it again, and the kernel dies (the traceback shows it was waiting for the new prompt after sending the interrupt).

I've tried both sendintr() and kill(signal.SIGINT), but neither seem to work.

Support for Cygwin on Windows

OK, just throwing this out there ... the problem is that there isn't the pexpect module for Windows.
(Actually the bash_kernel installs, appears in the menu but doesn't/can't work. The failed install should be detected).

Any chance of a pexpect-less version of bash_kernel?

install permission in raspberry pi

Hello,
I succesfully managed to install bash_kernel on a raspberry pi (raspbian stretch 2017-08-16) but I had to modify the commands in the main web page to use 'pip3' and 'python3'

The last command complained about write permission on /usr/local/share/jupyter so I had to create the directory and give permission to the user (probably not the best idea). Do you have a better alternative?

I did:

  • pip3 install bash_kernel
  • sudo mkdir /usr/local/share/jupyter
  • sudo chown ${USER} /usr/local/share/jupyter
  • python3 -m bash_kernel.install

Where to put .bashrc?

I have a .bashrc file in my home directory but it appears that it is not being read.

Where do I need to put it?

Running latest version on OS X.

Kernel crashes when Jupyter Notebook is started from JupyterHub

Whn trying to use the BASH kernel from a Jupyter Notebook started from
JupyterHub, I get the following traceback::

[I 2017-02-07 23:25:27.478 ubuntu kernelmanager:89] Kernel started: bd732170-24fd-4262-a6b3-37d2a1362006
[IPKernelApp] ERROR | UNKNOWN MESSAGE TYPE: u'comm_open'
[IPKernelApp] ERROR | UNKNOWN MESSAGE TYPE: u'comm_open'
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 228, in dispatch_shell
    handler(stream, idents, msg)
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 390, in execute_request
    user_expressions, allow_stdin)
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/bash_kernel/kernel.py", line 146, in do_execute
    self.bashwrapper.run_command(code.rstrip(), timeout=None)
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/pexpect/replwrap.py", line 95, in run_command
    if self._expect_prompt(timeout=timeout) == 1:
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/bash_kernel/kernel.py", line 44, in _expect_prompt
    timeout=None)
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/pexpect/spawnbase.py", line 383, in expect_exact
    pattern_list = [prepare_pattern(p) for p in pattern_list]
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/pexpect/spawnbase.py", line 377, in prepare_pattern
    self._pattern_type_err(pattern)
  File "/opt/Anaconda2-4.3.0-Linux-x86_64/lib/python2.7/site-packages/pexpect/spawnbase.py", line 172, in _pattern_type_err
    for ast in self.allowed_string_types])
TypeError: got <type 'str'> ('\r\n') as pattern, must be one of: <type 'unicode'>, pexpect.EOF, pexpect.TIMEOUT
[I 2017-02-07 23:27:27.719 ubuntu handlers:179] Saving file at /Untitled.ipynb

Evaluation of a simple cell containing the ls / command hangs forever and never displays any output.

Here are the versions of packages involved::

ubuntu@master001:~$ python2
Python 2.7.13 |Anaconda 4.3.0 (64-bit)| (default, Dec 20 2016, 23:09:15) 
...
>>> import bash_kernel 
>>> bash_kernel.__version__
'0.5'
>>> import pexpect
>>> pexpect.__version__
'4.2.1'

Warning when installing and running under Jupyter 4

Here is the warning message obtained during installation:

$ pip install bash_kernel
...
Successfully installed bash-kernel-0.4
$ python -m bash_kernel.install
/Users/ajmazurie/.pyenv/versions/_jupyter/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
Installing IPython kernel spec

And here is the message obtained when launching a notebook with the Bash kernel:

/Users/ajmazurie/.pyenv/versions/_jupyter/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
[IPKernelApp] ERROR | UNKNOWN MESSAGE TYPE: u'comm_open'

As far as I can tell the kernel seems to work well, however.

Thanks,
Aurelien

Remove kernelspec file on uninstall

When uninstalling with:

pip uninstall bash_kernel

the kernelspec directory & file is left behind, causing the bash kernel to still be offered in the Web UI and listed as an available kernel via the command line.

Broken Pipe Errors

Using any type of non-trivial pipe prints a "Broken pipe" error.

For example, use the following code snippet:
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;

Executing in bash behaves as expected:

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
3JT1JUE_NE8-CcgaJXfkESNfWLgiVIWd

Executing in ipython (notebook or console both give same error):

In [1]: < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
QgmPQRyp0u1Lllf6c4Y5mAE8FxM563A_tr: write error: Broken pipe
tr: write error

Typing env "breaks" the kernel

Running under IPython 4.0.0/Jupyter 4.0.4 if I run env in a cell, that works fine ... but subsequently all bash commands just provide '0' as output and after several commands the output of one cell corresponds to the command of another cell.

Of course, restarting the kernel puts things right again.

Experimenting I found that if I ran
env | grep -v ^PS1

This avoids the problem.

I don't understand the cause of this problem, but it would be good that the kernel could correct for this (which is presumably one of a class of similar problem?)

Could not install v 0.7

I tried to install bash_kernel on raspian.
Here my bash output:

jupyter-kernelspec list
Available kernels:
  javascript    /usr/local/share/jupyter/kernels/javascript
  python3       /usr/local/share/jupyter/kernels/python3

sudo pip3 install bash_kernel
Collecting bash_kernel
  Using cached bash_kernel-0.7-py2.py3-none-any.whl
Requirement already satisfied: pexpect>=4.0 in /usr/local/lib/python3.6/site-packages (from bash_kernel)
Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.6/site-packages (from pexpect>=4.0->bash_kernel)
Installing collected packages: bash-kernel
Successfully installed bash-kernel-0.7

sudo python3 -m bash_kernel.install
Installing IPython kernel spec

jupyter-kernelspec list
Available kernels:
  javascript    /usr/local/share/jupyter/kernels/javascript
  python3       /usr/local/share/jupyter/kernels/python3

No bash_kernel here :-(

After uninstall:

sudo pip3 uninstall bash_kernel
Uninstalling bash-kernel-0.7:
  /usr/local/lib/python3.6/site-packages/bash_kernel-0.7.dist-info/INSTALLER
  /usr/local/lib/python3.6/site-packages/bash_kernel-0.7.dist-info/LICENSE
  /usr/local/lib/python3.6/site-packages/bash_kernel-0.7.dist-info/METADATA
  /usr/local/lib/python3.6/site-packages/bash_kernel-0.7.dist-info/RECORD
  /usr/local/lib/python3.6/site-packages/bash_kernel-0.7.dist-info/WHEEL
  /usr/local/lib/python3.6/site-packages/bash_kernel/__init__.py
  /usr/local/lib/python3.6/site-packages/bash_kernel/__main__.py
  /usr/local/lib/python3.6/site-packages/bash_kernel/__pycache__/__init__.cpython-36.pyc
  /usr/local/lib/python3.6/site-packages/bash_kernel/__pycache__/__main__.cpython-36.pyc
  /usr/local/lib/python3.6/site-packages/bash_kernel/__pycache__/images.cpython-36.pyc
  /usr/local/lib/python3.6/site-packages/bash_kernel/__pycache__/install.cpython-36.pyc
  /usr/local/lib/python3.6/site-packages/bash_kernel/__pycache__/kernel.cpython-36.pyc
  /usr/local/lib/python3.6/site-packages/bash_kernel/images.py
  /usr/local/lib/python3.6/site-packages/bash_kernel/install.py
  /usr/local/lib/python3.6/site-packages/bash_kernel/kernel.py
Proceed (y/n)? y
  Successfully uninstalled bash-kernel-0.7

pip3 show bash_kernel

I install v 0.6:

sudo pip3 install bash_kernel==0.6
Collecting bash_kernel==0.6
  Using cached bash_kernel-0.6-py2.py3-none-any.whl
Requirement already satisfied: pexpect>=4.0 in /usr/local/lib/python3.6/site-packages (from bash_kernel==0.6)
Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.6/site-packages (from pexpect>=4.0->bash_kernel==0.6)
Installing collected packages: bash-kernel
Successfully installed bash-kernel-0.6

sudo python3 -m bash_kernel.install
Installing IPython kernel spec

jupyter-kernelspec list
Available kernels:
  bash          /usr/local/share/jupyter/kernels/bash
  javascript    /usr/local/share/jupyter/kernels/javascript
  python3       /usr/local/share/jupyter/kernels/python3

I don't know how to install v0.7 correct.

Why specify python3 for the kernel?

Why not let the user's default python executable be used? For a virtualenv or a conda env, this is taken care of naturally, and it could be handled with an alias or a path change otherwise.

Wont start

from PySide import QtGui, QtCore, QtSvg

ImportError: dlopen(/Users/sindhus/Library/Python/2.7/lib/python/site-packages/PySide/QtGui.so, 2): Library not loaded: libpyside-python2.7.1.2.dylib
Referenced from: /Users/sindhus/Library/Python/2.7/lib/python/site-packages/PySide/QtGui.so
Reason: image not found

How do I fix this? I have pyqt and pyside installed.
Thanks!

can't use git push / git pull

I was trying to create a jupyter notebook on git usage. But when I use:

git push origin master

It just keeps processing. It should actually ask the git username then password.

Is there any workaround for this or am I missing something?

OS: Linux 14.04.5

Add do_inspect?

How would you feel about a do_inspect method that pops up the -h output if you put a ? after a command?

No More Output

I'm not sure what changed upstream, but the Wrapper Kernels do not show output any more, in the notebook or the consoles. I'm using commit 1a650e5. Here's what I get from the qtconsole:

$ ipython qtconsole --kernel bash
NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049


To connect another client to this kernel, use:
    --existing kernel-28439.json
Traceback (most recent call last):
  File "/home/silvester/workspace/ipython/IPython/qt/base_frontend_mixin.py", line 138, in _dispatch
    handler(msg)
  File "/home/silvester/workspace/ipython/IPython/qt/console/frontend_widget.py", line 537, in _handle_stream
    self.append_stream(msg['content']['text'])
KeyError: 'text'

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

doesn't seem to generate incremental output

When running a long-running process that produces lots of output over time, it would be nice to see lines appear as they are generated. (That would seem to be a major reason for using pexpect, wouldn't it?)

However, when I use the bash_kernel, it only seems to display output from the shell when the subcommand completes.

Is this the way bash_kernel is supposed to behave?

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.