These are chat archives for ipython/ipython

5th
Oct 2015
john
@jcoady
Oct 05 2015 14:39
I created a custom kernel which I installed using the command
jupyter kernelspec install mykernel
from a local directory on my machine called mykernel. However, when I try to create a new jupyter notebook with my new kernel, it only works in when I am in the mykernel directory. Otherwise if I am in a different directory it says that the kernel is dead. How do I install my custom kernel so that jupyter can create a new notebook using it from any directory that I am working in. I am using a Windows 7 machine with Ipython/Jupyter version 4.0 .
Min RK
@minrk
Oct 05 2015 14:44
The kernelspec is just the information needed to start the kernel, e.g. argv: python -m mypackage. Installing the kernel itself is typically done via regular package managers, e.g. pip install mypackage for Python packages.
@stefanv I think IPython is a good choice, but obviously I'm biased. Depending on the work they intend to do and what hardware they intend to use, other things like dask.distributed or joblib might be appropriate to try.
john
@jcoady
Oct 05 2015 15:06
@minrk
I tried this and it did not work
argv: python -m mypackage.mykernel
but then I tried putting mykernel in IPython package directory and the following worked.
argv: python -m IPython.mykernel
So it seems that jupyter knows about the IPython package but not my custom mypackage package. How do I make jupyter aware of mypackage package.
Min RK
@minrk
Oct 05 2015 15:07
@jcoady install it, typically with pip or python setup.py.
john
@jcoady
Oct 05 2015 15:08
@minrk
I copied it to a preexisting package that was installed using pip.
pip install mypackage
and just copied the mykernel.py file into this mypackage but it failed to find it. But when I copied mykernel into the IPython package it found it.
Min RK
@minrk
Oct 05 2015 15:12
I'm not sure I understand how you installed it the first time.
Copying files around manually generally isn't how one installs things with Python, but if you want to do it, copy the file(s) into a site-packages directory (e.g. in the same directory as the IPython directory).
john
@jcoady
Oct 05 2015 15:15
My package is present in site-packages directory. I will try copying the mykernel.py file into one of the other packages in this directory and then update the kernel.json file to see if it finds it just like I did when I copied the mykernel.py file into the site-packages/IPython directory to get it to work.
john
@jcoady
Oct 05 2015 15:24
I copied mykernel.py into jinja2 package and set
argv: python -m jinja2.mykernel
and it worked. However if I try using
argv: python -m mypackage.mykernel
it doesn't work. Does jupyter import the IPython and jinja2 packages and that is why it is able to file mykernel in them?
Min RK
@minrk
Oct 05 2015 15:30
No, it does no importing. It just executes the command you give it.
Is there an __init__.py in mypackage?
john
@jcoady
Oct 05 2015 15:36
Yes there is an init.py which just contains one line
from .visual import *
do I need to add something to the init.py file?
I will try creating a new mypackage with just the mykernel.py and mykernel.json and see if I can get it to work without putting mykernel in a preexisting package.
john
@jcoady
Oct 05 2015 15:42
I will do that sometime later today and get back to you.
john
@jcoady
Oct 05 2015 17:08
OK I got it to work now with just the 3 files in site-packages/mypackage directory . The 3 files are kernel.json, mykernel.py and an empty init.py file.
john
@jcoady
Oct 05 2015 17:24

I created a new kernel by subclassing IPythonKernel
class MyKernel(IPythonKernel):

in the mykernel.py file. I would like to know if I can import python modules in the mykernel.py file so that they are available in the Jupyter notebook cells. For instance I imported
from math import *

in the mykernel.py file but I can't execute
a = cos(1.2)
a
in the notebook cell. Because it doesn't detect that math has been imported. I need to call
from math import *
in a notebook cell for it to work.
Sylvain Corlay
@SylvainCorlay
Oct 05 2015 17:56
Do you guys know if github supports mailmaps?
Kyle Kelley
@rgbkrk
Oct 05 2015 21:54
yes
Sylvain Corlay
@SylvainCorlay
Oct 05 2015 21:55
Got a reply from github, the rep said no.
Kyle Kelley
@rgbkrk
Oct 05 2015 21:55
oh, weird
eh
Sylvain Corlay
@SylvainCorlay
Oct 05 2015 22:08
well he might be wrong but it is good practice for us to keep the mailmap in any case
Stefan van der Walt
@stefanv
Oct 05 2015 22:56
@minrk Any comment on the parallel computing in Python question above?
Remi Rampin
@remram44
Oct 05 2015 23:09
GitHub has their own mailmap, in the sense that you can add more email addresses to your own GitHub account
Min RK
@minrk
Oct 05 2015 23:55
@stefanv I thought I answered. reposting, if it's not there for some reason.
I think IPython is a good choice, but obviously I'm biased. Depending on the work they intend to do and what hardware they intend to use, other things like dask.distributed or joblib might be appropriate to try.