<div dir="ltr"><div dir="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 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.</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="https://github.com/ipython/ipykernel/blob/34ca17011c1e79f65290b88f1deb18ac03e142af/ipykernel/kernelapp.py#L58">https://github.com/ipython/ipykernel/blob/34ca17011c1e79f65290b88f1deb18ac03e142af/ipykernel/kernelapp.py#L58</a></div><div><br></div><div>> How can I debug what's wrong and particularly is there a way to start that particular kernel, based on those kernel spec alone?</div><div><br></div><div>Normally those 'restarting 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 --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.<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 15 Feb 2019 at 23:10, Alessandro Dentella <<a href="mailto:sandro.dentella@gmail.com">sandro.dentella@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 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 arguments passed<br>
to what exactely? -m and --ext are for python/ipython, who interprets -f?<br>
<br>
The setup<br>
=========<br>
<br>
I have a django project whit a std virtualenv with a working kernel<br>
defined as follows:<br>
<br>
{<br>
    "env": {<br>
           "DJANGO_SETTINGS_MODULE": "web.settings",<br>
           "PYTHONPATH": "$PYTHONPATH:/misc/src/hg/thunder/siti/alma/django" },<br>
    "argv": [<br>
        "/home/sandro/.virtualenvs/alma/bin/python3.6",<br>
        "-m",<br>
        "ipykernel_launcher",<br>
        "-f",<br>
        "{connection_file}",<br>
        "--ext",<br>
        "django_extensions.management.notebook_extension"<br>
    ],<br>
    "display_name": "Alma ",<br>
    "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>
    "env": {<br>
           "DJANGO_SETTINGS_MODULE": "web.settings",<br>
           "PYTHONPATH": "$PYTHONPATH:/misc/src/hg/thunder/siti/alma/django/env" },<br>
    "argv": [<br>
        "/home/sandro/.virtualenvs/alma/bin/python3.6",<br>
        "-m",<br>
        "setup_jupyter",<br>
        "-f",<br>
        "{connection_file}",<br>
        "--ext",<br>
        "django_extensions.management.notebook_extension"<br>
    ],<br>
    "display_name": "Alma 2",<br>
    "language": "python"<br>
}<br>
<br>
Where setup_jupiter is in PYTHONPATH and uses site.addsitedir():<br>
<br>
   import os<br>
   import site<br>
   site.addsitedir(os.path.dirname(__file__))<br>
   import ipykernel_launcher<br>
<br>
Question<br>
========<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>
   [I 20:07:27.618 LabApp] Kernel started: 11cc7c35-b88b-4f87-ad42-bdf85f28c352<br>
   [I 20:07:28.230 LabApp] KernelRestarter: restarting kernel (2/5), new random ports<br>
   [I 20:07:31.236 LabApp] KernelRestarter: restarting kernel (3/5), new random ports<br>
   [I 20:07:34.244 LabApp] KernelRestarter: restarting kernel (4/5), new random ports<br>
   [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<br>
that particular kernel, based on those kernel spec alone?<br>
<br>
Sandro<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@python.org" target="_blank">IPython-dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/ipython-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/ipython-dev</a><br>
</blockquote></div>