Closed lmmx closed 8 years ago
Hmm, it should work with IPython 4, is it listed under $ jupyter-kernelspec list
? If not, perhaps something went wrong during the install. You could nuke it from pip
and pip install
again and paste the full output.
No it isn't... pip 7.1.2
via .../anaconda3/lib/python3.5/site-packages (python 3.5)
pip uninstall
⇒ Successfully uninstalled xonsh-kernel-0.1.0
pip -v --log ~/Desktop/xonsh_kernel_install.log install xonsh_kernel
cat ~/Desktop/xonsh_kernel_install.log
:Collecting xonsh-kernel
Getting page https://pypi.python.org/simple/xonsh-kernel/
Starting new HTTPS connection (1): pypi.python.org
"GET /simple/xonsh-kernel/ HTTP/1.1" 200 253
1 location(s) to search for versions of xonsh-kernel:
* https://pypi.python.org/simple/xonsh-kernel/
Getting page https://pypi.python.org/simple/xonsh-kernel/
Analyzing links from page https://pypi.python.org/simple/xonsh-kernel/
Found link https://pypi.python.org/packages/source/x/xonsh_kernel/xonsh_kernel-0.1.0.tar.gz#md5=d06811052fa6669481c288d74413096c (from https://pypi.python.org/simple/xonsh-kernel/), version: 0.1.0
Found link https://pypi.python.org/packages/source/x/xonsh_kernel/xonsh_kernel-0.1.0.zip#md5=7586e65b54c33f85c24b11483a975c35 (from https://pypi.python.org/simple/xonsh-kernel/), version: 0.1.0
Using version 0.1.0 (newest of versions: 0.1.0, 0.1.0)
Using cached wheel link: file:///home/louis/.cache/pip/wheels/eb/71/0e/003a5580cdbb259610300f19bd59d168ff6245eed2a3b450ae/xonsh_kernel-0.1.0-py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): metakernel>=0.9 in ./anaconda3/lib/python3.5/site-packages (from xonsh-kernel)
Requirement already satisfied (use --upgrade to upgrade): IPython>=3.0 in ./anaconda3/lib/python3.5/site-packages (from xonsh-kernel)
Installing collected packages: xonsh-kernel
Successfully installed xonsh-kernel-0.1.0
Cleaning up...
jupyter-kernelspec list
Available kernels:
igo /home/louis/.ipython/kernels/igo
python3 /home/louis/anaconda3/lib/python3.5/site-packages/ipykernel/resources
ir /home/louis/.local/share/jupyter/kernels/ir
julia 0.3 /home/louis/.local/share/jupyter/kernels/julia 0.3
julia-0.4 /home/louis/.local/share/jupyter/kernels/julia-0.4
matlab_kernel /home/louis/.local/share/jupyter/kernels/matlab_kernel
python2 /home/louis/.local/share/jupyter/kernels/python2
What version of xonsh are you on?
I just released a new version, please try pip install -U xonsh_kernel
.
Awfully sorry guys - I figured out it was due to the xonsh program at /usr/bin/xonsh
being hardcoded in the shebang line to #!/usr/bin/python3 -u
which is python3.4 (not Conda) whereas the actual python
command on my system (i.e. #!/usr/bin/env python -u
) points to python3.5 (via Anaconda3).
I installed xonsh
prior to setting up the Conda environment, so it was on the system python3 only, not Conda environment python(3), which Jupyter notebook accesses.
#!/usr/bin/python3 -u
from xonsh.main import main
main()
─────────────────────────────────────────────────────────────────────────
louis ~ $ /usr/bin/python -u
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
>>>
louis ~ $ /usr/bin/python3 -u
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
>>>
louis ~ $ python3 -u
Python 3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, 21:57:25)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
>>>
I ran pip install xonsh
(i.e. for Conda python3 pip3), and then installed the updated xonsh_kernel
and it now shows up in the kernels (hurrah!)
... the bad news is there are now 2, one seemingly installed via pip install xonsh
and one via pip install xonsh_kernel
(distinguished from the HTML id attributes of the menu items, as both are labelled "Xonsh")
id="kernel-submenu-xonsh"
[W 18:14:17.463 NotebookApp] Timeout waiting for kernel_info reply from 1573119f-e406-4023-9784-8b2941cdb29a
print("Hello world")
is never printed when entered and run in a cellid="kernel-submenu-xonsh_kernel"
Uploaded: gist of one cycle, STDERR and STDOUT (in which I ran first the xonsh
kernel, ran a print("Hello world")
cell [got no output], and then switched to the xonsh_kernel
kernel, which subsequently 'died'.
STDERR
important part for xonsh
kernel:NOW USING 'XONSH' KERNEL
[I 19:37:29.384 NotebookApp] Kernel started: 99d9a3b5-85f7-4bee-9680-02429e007a1d
[W 19:37:39.403 NotebookApp] Timeout waiting for kernel_info reply from 99d9a3b5-85f7-4bee-9680-02429e007a1d
[I 19:38:09.511 NotebookApp] Saving file at /ch1/Chapter 1.ipynb
ATTEMPTED CALCULATION USING 'XONSH' KERNEL
(no output, but also no 'kernel died' error message so unclear what happened)
STDERR
important part for xonsh_kernel
kernel:NOW USING 'XONSH_KERNEL' KERNEL
[I 19:38:37.988 NotebookApp] Kernel started: f88e7339-c0b9-45a0-b0aa-c34b112bcac4
/home/louis/anaconda3/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)
[I 19:38:43.988 NotebookApp] KernelRestarter: restarting kernel (1/5)
[W 19:38:48.019 NotebookApp] Timeout waiting for kernel_info reply from f88e7339-c0b9-45a0-b0aa-c34b112bcac4
/home/louis/anaconda3/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.
(then repeat)
STDOUT
important part for xonsh
kernel: there was no output to STDOUTSTDERR
important part for xonsh_kernel
kernel:NOW USING 'XONSH_KERNEL' KERNEL
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/louis/anaconda3/lib/python3.5/runpy.py in _run_module_as_main(mod_name='xonsh_kernel', 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='xonsh_kernel', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fc97d07d780>, origin='/home/louis/anaconda3/lib/python3.5/site-packages/xonsh_kernel.py')
171
172 def run_module(mod_name, init_globals=None,
/home/louis/anaconda3/lib/python3.5/runpy.py in _run_code(code=<code object <module> at 0x7fc97b3eedb0, file "/...python3.5/site-packages/xonsh_kernel.py", line 1>, run_globals={'IPKernelApp': <class 'ipykernel.kernelapp.IPKernelApp'>, 'MetaKernel': <class 'metakernel._metakernel.MetaKernel'>, 'ProcessMetaKernel': <class 'metakernel.process_metakernel.ProcessMetaKernel'>, 'REPLWrapper': <class 'metakernel.replwrap.REPLWrapper'>, 'XonshKernel': <class '__main__.XonshKernel'>, '__builtins__': <module 'builtins' (built-in)>, '__cached__': '/home/louis/anaconda3/lib/python3.5/site-packages/__pycache__/xonsh_kernel.cpython-35.pyc', '__doc__': None, '__file__': '/home/louis/anaconda3/lib/python3.5/site-packages/xonsh_kernel.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, ...}, init_globals=None, mod_name='__main__', mod_spec=ModuleSpec(name='xonsh_kernel', loader=<_frozen_...da3/lib/python3.5/site-packages/xonsh_kernel.py'), pkg_name='', script_name=None)
83 __package__ = pkg_name,
84 __spec__ = mod_spec)
---> 85 exec(code, run_globals)
global exec = undefined
code = <code object <module> at 0x7fc97b3eedb0, file "/home/louis/anaconda3/lib/python3.5/site-packages/xonsh_kernel.py", line 1>
run_globals = {'ProcessMetaKernel': <class 'metakernel.process_metakernel.ProcessMetaKernel'>, 'XonshKernel': <class '__main__.XonshKernel'>, 'MetaKernel': <class 'metakernel._metakernel.MetaKernel'>, 'IPKernelApp': <class 'ipykernel.kernelapp.IPKernelApp'>, 'u': <function u at 0x7fc973a5c7b8>, '__builtins__': <module 'builtins' (built-in)>, 'os': <module 'os' from '/home/louis/anaconda3/lib/python3.5/os.py'>, '__name__': '__main__', '__version__': '0.2.0', '__spec__': ModuleSpec(name='xonsh_kernel', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fc97d07d780>, origin='/home/louis/anaconda3/lib/python3.5/site-packages/xonsh_kernel.py'), 'builtins': <module 'builtins' (built-in)>, '__package__': '', '__doc__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7fc97d07d780>, 're': <module 're' from '/home/louis/anaconda3/lib/python3.5/re.py'>, 'REPLWrapper': <class 'metakernel.replwrap.REPLWrapper'>, 'completer': <module 'xonsh.completer' from '/home/louis/.local/lib/python3.5/site-packages/xonsh/completer.py'>, 'print_function': _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 65536), '__file__': '/home/louis/anaconda3/lib/python3.5/site-packages/xonsh_kernel.py', '__cached__': '/home/louis/anaconda3/lib/python3.5/site-packages/__pycache__/xonsh_kernel.cpython-35.pyc'}
86 return run_globals
87
/home/louis/anaconda3/lib/python3.5/site-packages/xonsh_kernel.py in <module>()
74 if __name__ == '__main__':
75 from IPython.kernel.zmq.kernelapp import IPKernelApp
---> 76 IPKernelApp.launch_instance(kernel_class=XonshKernel)
global IPKernelApp.launch_instance = <bound method Application.launch_instance of <class 'ipykernel.kernelapp.IPKernelApp'>>
global kernel_class = undefined
global XonshKernel = <class '__main__.XonshKernel'>
/home/louis/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py in launch_instance(cls=<class 'ipykernel.kernelapp.IPKernelApp'>, argv=None, **kwargs={'kernel_class': <class '__main__.XonshKernel'>})
589 """
590 app = cls.instance(**kwargs)
--> 591 app.initialize(argv)
app.initialize = <bound method IPKernelApp.initialize of <ipykernel.kernelapp.IPKernelApp object at 0x7fc973a683c8>>
argv = None
592 app.start()
593
/home/louis/anaconda3/lib/python3.5/site-packages/ipykernel/kernelapp.py in initialize(self=<ipykernel.kernelapp.IPKernelApp object>, argv=None)
/home/louis/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py in catch_config_error(method=<function IPKernelApp.initialize>, app=<ipykernel.kernelapp.IPKernelApp object>, *args=(None,), **kwargs={})
73 """
74 try:
---> 75 return method(app, *args, **kwargs)
method = <function IPKernelApp.initialize at 0x7fc97394d598>
app = <ipykernel.kernelapp.IPKernelApp object at 0x7fc973a683c8>
args = (None,)
kwargs = {}
76 except (TraitError, ArgumentError) as e:
77 app.print_help()
/home/louis/anaconda3/lib/python3.5/site-packages/ipykernel/kernelapp.py in initialize(self=<ipykernel.kernelapp.IPKernelApp object>, argv=None)
380 self.init_io()
381 self.init_signal()
--> 382 self.init_kernel()
self.init_kernel = <bound method IPKernelApp.init_kernel of <ipykernel.kernelapp.IPKernelApp object at 0x7fc973a683c8>>
383 # shell init steps
384 self.init_path()
/home/louis/anaconda3/lib/python3.5/site-packages/ipykernel/kernelapp.py in init_kernel(self=<ipykernel.kernelapp.IPKernelApp object>)
319 log=self.log,
320 profile_dir=self.profile_dir,
--> 321 user_ns=self.user_ns,
global user_ns = undefined
self.user_ns = None
322 )
323 kernel.record_ports(self.ports)
/home/louis/anaconda3/lib/python3.5/site-packages/traitlets/config/configurable.py in instance(cls=<class '__main__.XonshKernel'>, *args=(), **kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <ipykernel.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <jupyter_client.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})
378 # Create and save the instance
379 if cls._instance is None:
--> 380 inst = cls(*args, **kwargs)
inst = undefined
cls = <class '__main__.XonshKernel'>
args = ()
kwargs = {'session': <jupyter_client.session.Session object at 0x7fc973949a90>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object at 0x7fc97395cd68>, <zmq.eventloop.zmqstream.ZMQStream object at 0x7fc97395cf98>], 'stdin_socket': <zmq.sugar.socket.Socket object at 0x7fc973932a68>, 'profile_dir': <IPython.core.profiledir.ProfileDir object at 0x7fc973949fd0>, 'iopub_socket': <zmq.sugar.socket.Socket object at 0x7fc973932ac8>, 'parent': <ipykernel.kernelapp.IPKernelApp object at 0x7fc973a683c8>, 'user_ns': None, 'log': <logging.Logger object at 0x7fc973a689b0>}
381 # Now make sure that the instance will also be returned by
382 # parent classes' _instance attribute.
/home/louis/anaconda3/lib/python3.5/site-packages/metakernel/process_metakernel.py in __init__(self=<__main__.XonshKernel object>, **kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <ipykernel.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <jupyter_client.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})
40 self.wrapper = None
41 self.repr = str
---> 42 self._start()
self._start = <bound method ProcessMetaKernel._start of <__main__.XonshKernel object at 0x7fc97395cfd0>>
43
44 def _start(self):
/home/louis/anaconda3/lib/python3.5/site-packages/metakernel/process_metakernel.py in _start(self=<__main__.XonshKernel object>)
45 if not self.wrapper is None:
46 self.wrapper.child.terminate()
---> 47 self.wrapper = self.makeWrapper()
self.wrapper = None
self.makeWrapper = <bound method XonshKernel.makeWrapper of <__main__.XonshKernel object at 0x7fc97395cfd0>>
48
49 def do_execute_direct(self, code):
/home/louis/anaconda3/lib/python3.5/site-packages/xonsh_kernel.py in makeWrapper(self=<__main__.XonshKernel object>)
43 extra_init_cmd = "$PAGER='cat'"
44 os.environ['PAGER'] = 'cat'
---> 45 self.completer = completer.Completer()
self.completer = undefined
global completer.Completer = <class 'xonsh.completer.Completer'>
46 return REPLWrapper('xonsh', prompt_regex, prompt_change_cmd,
47 prompt_emit_cmd=prompt_emit_cmd,
/home/louis/.local/lib/python3.5/site-packages/xonsh/completer.py in __init__(self=<xonsh.completer.Completer object>)
89 try:
90 # FIXME this could be threaded for faster startup times
---> 91 self._load_bash_complete_funcs()
self._load_bash_complete_funcs = <bound method Completer._load_bash_complete_funcs of <xonsh.completer.Completer object at 0x7fc978a2d780>>
92 # or we could make this lazy
93 self._load_bash_complete_files()
/home/louis/.local/lib/python3.5/site-packages/xonsh/completer.py in _load_bash_complete_funcs(self=<xonsh.completer.Completer object>)
323 def _load_bash_complete_funcs(self):
324 self.bash_complete_funcs = bcf = {}
--> 325 inp = self._source_completions()
inp = undefined
self._source_completions = <bound method Completer._source_completions of <xonsh.completer.Completer object at 0x7fc978a2d780>>
326 if len(inp) == 0:
327 return
/home/louis/.local/lib/python3.5/site-packages/xonsh/completer.py in _source_completions(self=<xonsh.completer.Completer object>)
313 def _source_completions(self):
314 srcs = []
--> 315 for f in builtins.__xonsh_env__.get('BASH_COMPLETIONS'):
f = undefined
global builtins.__xonsh_env__.get = <built-in method get of dict object at 0x7fc97b3fbc88>
316 if os.path.isfile(f):
317 # We need to "Unixify" Windows paths for Bash to understand
TypeError: 'NoneType' object is not iterable
---------------------------------------------------------------------------
Serving notebooks from local directory: /home/louis/Path/To/Notebook
1 active kernels
The IPython Notebook is running at: http://localhost:8888/
Shutdown this notebook server (y/[n])?
KILLED NOTEBOOK
pip install xonsh
and pip install -U xonsh_kernel
and get the same as before, the kernel with "xonsh_kernel" in the menu item ID dies, while the one with just "xonsh" in the ID times out.
xonsh
with the -U
flag: says cannot build wheel, permission denied to /usr/local/share/jupyter/kernels/xonsh
(so I presume it attempts to install the Jupyter kernel when it detects Jupyter is on the system, which explains the 2 menu items)Sorry if I've gone about this the wrong way.
I was getting
/usr/bin/env: python -u: No such file or directory
so I rewrote the xonsh
executable file as noted in this xonsh
thread as:
#!/usr/bin/env sh
export PYTHONUNBUFFERED="XONSH_SET"
/usr/bin/env python -c "from xonsh.main import main; main()"
and solved this issue. The kernel still doesn't work though so I'll leave the logs above in case they help debug the issue.
Does it work if you: export PYTHONUNBUFFERED="XONSH_SET"; jupyter notebook
?
@blink1073: No change there unfortunately
Bummer, I'm afraid I'm out of ideas on this one.
I get the same as @lmmx, both with using xonsh and xonsh_kernel as the kernel.
There is more discussion of the fix at scopatz/xonsh#565, which I think just needs to be cleaned up to provide a xonsh.sh
script.
Cheers, I still get this problem even with PYTHONUNBUFFERED set - I get no response from the "xonsh" kernel, while the "xonsh_kernel" kernel gives me the error in the TypeError referenced in the first post.
An interesting thing to note is that when when I use the "xonsh" kernel, i while I get very high CPU usage: effectively one CPU fully utilised. When I look at whats using it, it is a bash process, running a scrip that I think is created by foreign_shells.py, at least it starts:
bash -i -c echo __XONSH_ENV_BEG__?env?echo __XONSH_ENV_END__?echo __XONSH_ALIAS_BEG__?alias?echo __XONSH_ALIAS_END__?echo __XONSH_FUNCS_BEG__?# get function names from declare?declstr=$(declare -F)?read -r -a
When I kill jupyter, this continues to run, one of these had been running for 18 hours before I caught it. Oh, and they need kill -9 to get rid of them.
Hi @IanSudbery, Ok can you try a couple of things then please? The first is to see if we can get this to stop by not loading bash. Set the foreign shells section of your config file (~/.local/config/xonsh/config.json) to empty:
{"foreign_shells": []}
Does the high-cpu Bash process still get spawned? The second thing to try is to turn off the safety and have bash throw an exception. For this, set you config file to:
{"foreign_shells": [
{"shell": "bash", "safe": false}
]
}
Does this throw an error, and if so, what?
Note that these can be separate files that you pass in at the command line via xonsh --config-path <file>
.
Hi @scopatz,
Thanks for your help. If I set foriegn_shells to empty, then I don't get the high CPU Bash process. The kernel sort of works...
In python mode, I can type python and get responses. However, in subprocess mode, the output goes to the terminal I started jupyter from rather than to the notebook. At this point, I have lost control of the terminal ^C, ^Z do nothing and I have to kill the juptyer process from elsewhere.
If I set bash to unsafe, I get the same as before ... no response at all from the kernel and a high-cpu Bash process.
@IanSudbery - OK, some progress at least. What version of jupyter are you using?
@scopatz -jupyter 4.0.6
Hmmm OK. I am seeing this issue now too.
This should be fixed on master xonsh now.
I can't verify, because I could not reproduce, I'll wait for @IanSudbery or @lmmx to chime in.
Sorry, I've been away, I'll try to test this out today.
Works great now from both Xonsh master and here.
Great, thanks, closing as fixed.
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:But no entry in
~/.local/share/jupyter/kernels
(wherematlab_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 runipython qtconsole --kernel=xonsh_kernel
Have I missed something obvious here or is this a work in progress..? Or perhaps not compatible with IPython 4 yet ?