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

Jupyter C++ kernel dies repeatedly #171

Open
Yancey2126 opened this issue Jan 31, 2018 · 2 comments
Open

Jupyter C++ kernel dies repeatedly #171

Yancey2126 opened this issue Jan 31, 2018 · 2 comments

Comments

@Yancey2126
Copy link

I installed cling and libgcc following this article:
http://shuvomoy.github.io/blog/programming/2016/08/04/Cpp-kernel-for-Jupyter.html

However, after running jupyter notebook, I can see C++ except that the kernel can never start and died repeatedly.

KernelRestarter: restarting kernel (4/5) kernel 8d8df6db-061d-4d07-87f4-b230de31a007 restarted Traceback (most recent call last): File "/usr/local/bin/jupyter-cling-kernel", line 6, in <module> exec(compile(open(__file__).read(), __file__, 'exec')) File "/Users/yangchen/Desktop/C++/clingMac/share/cling/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module> main() File "/Users/yangchen/Desktop/C++/clingMac/share/cling/Jupyter/kernel/clingkernel.py", line 354, in main ClingKernelApp.launch_instance() File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 657, in launch_instance app.initialize(argv) File "<decorator-gen-121>", line 2, in initialize File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error return method(app, *args, **kwargs) File "/Library/Python/2.7/site-packages/ipykernel/kernelapp.py", line 457, in initialize self.init_kernel() File "/Library/Python/2.7/site-packages/ipykernel/kernelapp.py", line 368, in init_kernel user_ns=self.user_ns, File "/Library/Python/2.7/site-packages/traitlets/config/configurable.py", line 412, in instance inst = cls(*args, **kwargs) File "/Users/yangchen/Desktop/C++/clingMac/share/cling/Jupyter/kernel/clingkernel.py", line 100, in __init__ clingInPath = shutil.which('cling') AttributeError: 'module' object has no attribute 'which' [W 13:44:34.272 NotebookApp] KernelRestarter: restart failed

I have no idea what is going on.

@dabro
Copy link

dabro commented Feb 17, 2018

TL;DR: use Python 3.3 or higher.

Python 2.7 doesn't have which method on shutil. See https://stackoverflow.com/questions/9877462/is-there-a-python-equivalent-to-the-which-command .

There used to be code that would catch this:

        except AttributeError:
            from distutils.spawn import find_executable
            whichCling = find_executable('cling')

and default to find_executable, but that seems to have been dropped in the last couple revisions. Specifically: 3848d29#diff-86d66e408680d0ec46117add5d297db7 lines 111-113
Maybe it didn't work? You could try adding it back and move the try: from line 107 of the most recent commit to line 100:

def __init__(self, **kwargs):
         super(ClingKernel, self).__init__(**kwargs)

         try:
           clingInPath = shutil.which('cling')
           if not clingInPath:
               from distutils.spawn import find_executable
               clingInPath = find_executable('cling')
           if not clingInPath:
               raise RuntimeError('Cannot find cling in $PATH. No cling, no fun.')

           whichCling = os.readlink(clingInPath)
           whichCling = os.path.join(os.path.dirname(clingInPath), whichCling)
         except OSError as e:
             #If cling is not a symlink try a regular file
             #readlink returns POSIX error EINVAL (22) if the
             #argument is not a symlink
             if e.args[0] == 22:
                whichCling = clingInPath
             else:
                 raise e
        except AttributeError:
            from distutils.spawn import find_executable
            whichCling = find_executable('cling')

@yiyang186
Copy link

I corrected it: clingInPath = 'path/to/cling' ... it works, but urgly.

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

3 participants