Re: kernel spect and how to thest them
Thomas Kluyver <[email protected]> Sat, 16 Feb 2019 10:46:39 +0000
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <CAOvn4qiSpWmy4qJOHA7pkDqM7XpHaBf068X=F6ssA64MA0KvcA@mail.gmail.com> |
--===============7128222135781120666== Content-Type: multipart/alternative; boundary="000000000000d5b1df0582009cba" --000000000000d5b1df0582009cba Content-Type: text/plain; charset="UTF-8" Hi Sandro, > I'd like to bettere understand "argv" list. It's the arguments passed to what exactely? To the operating system. It spawns a process with subprocess.Popen(), and those are the arguments for it. It's like running the command from a shell. > -m and --ext are for python/ipython, who interprets -f? The -f flag is for ipykernel, defined here: https://github.com/ipython/ipykernel/blob/34ca17011c1e79f65290b88f1deb18ac03e142af/ipykernel/kernelapp.py#L58 > How can I debug what's wrong and particularly is there a way to start that particular kernel, based on those kernel spec alone? Normally those 'restarting kernel' messages come with a traceback saying what went wrong. I'm not sure why they don't in your case. You can run a kernel through Jupyter by running 'jupyter kernel --kernel your-kernel-name' (where your-kernel-name is whatever you called the folder with kernel.json in). Alternatively, you can set the environment variables in your shell, join up argv with spaces, and run that in the shell. On Fri, 15 Feb 2019 at 23:10, Alessandro Dentella <[email protected]> wrote: > Hi, > > I'd like to bettere understand "argv" list. It's the arguments passed > to what exactely? -m and --ext are for python/ipython, who interprets -f? > > The setup > ========= > > I have a django project whit a std virtualenv with a working kernel > defined as follows: > > { > "env": { > "DJANGO_SETTINGS_MODULE": "web.settings", > "PYTHONPATH": > "$PYTHONPATH:/misc/src/hg/thunder/siti/alma/django" }, > "argv": [ > "/home/sandro/.virtualenvs/alma/bin/python3.6", > "-m", > "ipykernel_launcher", > "-f", > "{connection_file}", > "--ext", > "django_extensions.management.notebook_extension" > ], > "display_name": "Alma ", > "language": "python" > } > > From a jupyter lab I can connect to that and it just works fine. > > In my normal setup I use buildout that means I have an "empty" > vitualenv and a scipt that initializes the sys.path. So I tried to > modify the configuration as follows: > > { > "env": { > "DJANGO_SETTINGS_MODULE": "web.settings", > "PYTHONPATH": > "$PYTHONPATH:/misc/src/hg/thunder/siti/alma/django/env" }, > "argv": [ > "/home/sandro/.virtualenvs/alma/bin/python3.6", > "-m", > "setup_jupyter", > "-f", > "{connection_file}", > "--ext", > "django_extensions.management.notebook_extension" > ], > "display_name": "Alma 2", > "language": "python" > } > > Where setup_jupiter is in PYTHONPATH and uses site.addsitedir(): > > import os > import site > site.addsitedir(os.path.dirname(__file__)) > import ipykernel_launcher > > Question > ======== > > But this modified kernel spec does not work (sys.path it's correclty > setup due to a custom path.pth) > > Jupiter lab (run in a different virtualenv) complains: > > [I 20:07:27.618 LabApp] Kernel started: > 11cc7c35-b88b-4f87-ad42-bdf85f28c352 > [I 20:07:28.230 LabApp] KernelRestarter: restarting kernel (2/5), new > random ports > [I 20:07:31.236 LabApp] KernelRestarter: restarting kernel (3/5), new > random ports > [I 20:07:34.244 LabApp] KernelRestarter: restarting kernel (4/5), new > random ports > [W 20:07:37.249 LabApp] KernelRestarter: restart failed > > > How can I debug what's wrong and particularly is there a way to start > that particular kernel, based on those kernel spec alone? > > Sandro > _______________________________________________ > IPython-dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/ipython-dev > --000000000000d5b1df0582009cba Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div>Hi Sandro,</div><div><br></div><div>= > I'd like to bettere understand "argv" list. It's the= arguments passed to what exactely?</div><div><br></div><div>To the operati= ng system. It spawns a process with subprocess.Popen(), and those are the a= rguments for it. It's like running the command from a shell.</div><div>= <br></div><div>> -m and --ext are for python/ipython, who interprets -f?= </div><div><br></div><div>The -f flag is for ipykernel, defined here:</div>= <div><a href=3D"https://github.com/ipython/ipykernel/blob/34ca17011c1e79f65= 290b88f1deb18ac03e142af/ipykernel/kernelapp.py#L58">https://github.com/ipyt= hon/ipykernel/blob/34ca17011c1e79f65290b88f1deb18ac03e142af/ipykernel/kerne= lapp.py#L58</a></div><div><br></div><div>> How can I debug what's wr= ong and particularly is there a way to start that particular kernel, based = on those kernel spec alone?</div><div><br></div><div>Normally those 're= starting kernel' messages come with a traceback saying what went wrong.= I'm not sure why they don't in your case.</div><div><br></div><div= >You can run a kernel through Jupyter by running 'jupyter kernel --kern= el your-kernel-name' (where your-kernel-name is whatever you called the= folder with kernel.json in). Alternatively, you can set the environment va= riables in your shell, join up argv with spaces, and run that in the shell.= <br></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class= =3D"gmail_attr">On Fri, 15 Feb 2019 at 23:10, Alessandro Dentella <<a hr= ef=3D"mailto:[email protected]">[email protected]</a>> w= rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p= x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br> <br> I'd like to bettere understand "argv" list. It's the argu= ments passed<br> to what exactely? -m and --ext are for python/ipython, who interprets -f?<b= r> <br> The setup<br> =3D=3D=3D=3D=3D=3D=3D=3D=3D<br> <br> I have a django project whit a std virtualenv with a working kernel<br> defined as follows:<br> <br> {<br> =C2=A0 =C2=A0 "env": {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"DJANGO_SETTINGS_MODULE"= : "web.settings",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"PYTHONPATH": "$PYT= HONPATH:/misc/src/hg/thunder/siti/alma/django" },<br> =C2=A0 =C2=A0 "argv": [<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "/home/sandro/.virtualenvs/alma/bin/python= 3.6",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "-m",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "ipykernel_launcher",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "-f",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "{connection_file}",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "--ext",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "django_extensions.management.notebook_ext= ension"<br> =C2=A0 =C2=A0 ],<br> =C2=A0 =C2=A0 "display_name": "Alma ",<br> =C2=A0 =C2=A0 "language": "python"<br> }<br> <br> From a jupyter lab I can connect to that and it just works fine.<br> <br> In my normal setup I use buildout that means I have an "empty"<br= > vitualenv and a scipt that initializes the sys.path. So I tried to<br> modify the configuration as follows:<br> <br> {<br> =C2=A0 =C2=A0 "env": {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"DJANGO_SETTINGS_MODULE"= : "web.settings",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"PYTHONPATH": "$PYT= HONPATH:/misc/src/hg/thunder/siti/alma/django/env" },<br> =C2=A0 =C2=A0 "argv": [<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "/home/sandro/.virtualenvs/alma/bin/python= 3.6",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "-m",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "setup_jupyter",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "-f",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "{connection_file}",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "--ext",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 "django_extensions.management.notebook_ext= ension"<br> =C2=A0 =C2=A0 ],<br> =C2=A0 =C2=A0 "display_name": "Alma 2",<br> =C2=A0 =C2=A0 "language": "python"<br> }<br> <br> Where setup_jupiter is in PYTHONPATH and uses site.addsitedir():<br> <br> =C2=A0 =C2=A0import os<br> =C2=A0 =C2=A0import site<br> =C2=A0 =C2=A0site.addsitedir(os.path.dirname(__file__))<br> =C2=A0 =C2=A0import ipykernel_launcher<br> <br> Question<br> =3D=3D=3D=3D=3D=3D=3D=3D<br> <br> But this modified kernel spec does not work (sys.path it's correclty<br= > setup due to a custom path.pth)<br> <br> Jupiter lab (run in a different virtualenv) complains:<br> <br> =C2=A0 =C2=A0[I 20:07:27.618 LabApp] Kernel started: 11cc7c35-b88b-4f87-ad4= 2-bdf85f28c352<br> =C2=A0 =C2=A0[I 20:07:28.230 LabApp] KernelRestarter: restarting kernel (2/= 5), new random ports<br> =C2=A0 =C2=A0[I 20:07:31.236 LabApp] KernelRestarter: restarting kernel (3/= 5), new random ports<br> =C2=A0 =C2=A0[I 20:07:34.244 LabApp] KernelRestarter: restarting kernel (4/= 5), new random ports<br> =C2=A0 =C2=A0[W 20:07:37.249 LabApp] KernelRestarter: restart failed<br> <br> <br> How can I debug what's wrong and particularly is there a way to start<b= r> that particular kernel, based on those kernel spec alone?<br> <br> Sandro<br> _______________________________________________<br> IPython-dev mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">IPython-dev@pyt= hon.org</a><br> <a href=3D"https://mail.python.org/mailman/listinfo/ipython-dev" rel=3D"nor= eferrer" target=3D"_blank">https://mail.python.org/mailman/listinfo/ipython= -dev</a><br> </blockquote></div> --000000000000d5b1df0582009cba-- --===============7128222135781120666== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ IPython-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/ipython-dev --===============7128222135781120666==--