Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xonsh kernel Module 'builtins' has no attribute __xonsh_shell__ #13

Open
BoPeng opened this issue Oct 23, 2019 · 6 comments
Open

xonsh kernel Module 'builtins' has no attribute __xonsh_shell__ #13

BoPeng opened this issue Oct 23, 2019 · 6 comments

Comments

@BoPeng
Copy link

BoPeng commented Oct 23, 2019

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
@WardThomas
Copy link

similar issues are found with ipython on Debian 10, python 3.7 , xonsh_kernel installed via pipenv

pipenv install xonsh_kernel
pipenv shell
python -m xonsh_kernel.install
ipython console --kernel calysto_xonsh

In [1]: echo "ddd"
:
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/home//.local/share/virtualenvs/-bk1jwvoh/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "/home//.local/share/virtualenvs/-bk1jwvoh/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home//.local/share/virtualenvs/-bk1jwvoh/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/home//.local/share/virtualenvs/-bk1jwvoh/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 541, in execute_request
user_expressions, allow_stdin,
File "/home//.local/share/virtualenvs/-bk1jwvoh/lib/python3.7/site-packages/metakernel/_metakernel.py", line 395, in do_execute
retval = self.do_execute_direct(code)
File "/home//.local/share/virtualenvs/-bk1jwvoh/lib/python3.7/site-packages/xonsh_kernel/kernel.py", line 45, in do_execute_direct
out, err, interrupted = self._do_execute_direct(code)
File "/home//.local/share/virtualenvs/-bk1jwvoh/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'

@scopatz
Copy link

scopatz commented Oct 23, 2019

__xonsh_shell__ was renamed to __xonsh__.shell many versions ago. That should be the only update (and similar renames) that is needed. The deprecation warnings and proxies were removed in v0.9.9: https://xon.sh/changelog#v0-9-9

@BoPeng
Copy link
Author

BoPeng commented Oct 24, 2019

$ pip list | grep xon
xonsh                  0.9.13.dev1 
xonsh-kernel           0.4.1       

So the problem should be with xonsh-kernel, which has not been updated with the newer versions of xonsh.

@WardThomas
Copy link

Hello BoPeng, thanks for following that up

I have manged to get the Calysto/xonsh_kernel to work with Jupyter lab

I updated python3.7/site-packages/xonsh_kernel/kernel.py on my machine by replacing all occurrences of

  • xonsh_history with xonsh.history
  • xonsh_shell with xonsh.shell
  • xonsh_env with xonsh.env

and jupyter lab now works with the Calysto/xonsh_kernel t

I left these statements as is
swap(builtins, 'xonsh_stdout_uncaptured', out),
swap(builtins, 'xonsh_stderr_uncaptured', err), \

but they might need changing to
swap(builtins, 'xonsh.stdout_uncaptured', out), \

here is my modified kernel.py file

kernel.TXT
swap(builtins, 'xonsh.stderr_uncaptured', err), \

regards

@BoPeng
Copy link
Author

BoPeng commented Oct 24, 2019

@WardThomas Could you please create a PR? @blink1073 would be happy to take a look and merge it, even add you as a maintainer of the project.

@blink1073
Copy link
Contributor

Seconded 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants