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

Ansible Kernel 0.8.0 did not work with Python3 #65

Closed
sky-joker opened this issue Aug 28, 2018 · 0 comments
Closed

Ansible Kernel 0.8.0 did not work with Python3 #65

sky-joker opened this issue Aug 28, 2018 · 0 comments

Comments

@sky-joker
Copy link
Contributor

Describe the bug

When Ansible Kernel 0.8.0 is running in Python 3, the following error occurred.
The same error does not occur in python2.

Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jupyter/venv/lib64/python3.6/site-packages/ansible_kernel/__main__.py", line 6, in <module>
    IPKernelApp.launch_instance(kernel_class=AnsibleKernel)
  File "/home/jupyter/venv/lib64/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/jupyter/venv/lib64/python3.6/site-packages/ipykernel/kernelapp.py", line 483, in start
    self.kernel.start()
  File "/home/jupyter/venv/lib64/python3.6/site-packages/ipykernel/kernelbase.py", line 290, in start
    self._publish_status('starting')
  File "/home/jupyter/venv/lib64/python3.6/site-packages/ipykernel/kernelbase.py", line 327, in _publish_status
    ident=self._topic('status'),
  File "/home/jupyter/venv/lib64/python3.6/site-packages/jupyter_client/session.py", line 748, in send
    stream.send_multipart(to_send, copy=copy)
  File "/home/jupyter/venv/lib64/python3.6/site-packages/ansible_kernel/kernel.py", line 68, in send_multipart
    result = channel.send_multipart(msg, *args, **kwargs)
  File "/home/jupyter/venv/lib64/python3.6/site-packages/ansible_kernel/kernel.py", line 1173, in send_multipart
    if msg0.startswith("comm"):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

To Reproduce

$ python36 -m venv venv
$ source venv/bin/activate
$ pip3 install ansible
$ pip3 install jupyter
$ pip3 install ansible-kernel
$ python -m ansible_kernel.install
$ jupyter notebook

Screenshots

Desktop (please complete the following information):

  • OS: CentOS Linux release 7.5.1804 (Core)
  • Browser chrome
  • Version 68.0.3440.106
  • Jupyter 4.4.0
  • Jupyter lab 0.34.4

Smartphone (please complete the following information):

Additional context

I fixed the bug as follows.

--- before/kernel.py    2018-08-29 02:06:43.781003421 +0900
+++ after/kernel.py 2018-08-29 02:06:37.782995367 +0900
@@ -1170,7 +1170,7 @@
             msg3_data = json.loads(msg3)
             msg6_data = json.loads(msg6)

-            if msg0.startswith("comm"):
+            if msg0.startswith(b"comm"):
                 _, _, comm_id = msg0.partition('-')
                 if msg3_data['msg_type'] == 'comm_open' and msg6_data['comm_id'] == comm_id:
                     self.update_widget(comm_id, msg6_data.get('data', {}).get('state', {}))

thanks.

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

1 participant