Repository: jupyterhub/jupyterhub

Issue:
Invalid argument: '--cookie-name=jupyter-hub-token-MYUSERNAME'
I can't run cells in py notebooks, I got a popup `The kernel appears to have died`

Here's the log running jupyterhub from master branch

```
[IPKernelApp] CRITICAL | Bad config encountered during initialization:
[IPKernelApp] CRITICAL | Invalid argument: '--cookie-name=jupyter-hub-token-ben'
2014-09-14 20:53:59.865 [SingleUserNotebookApp] WARNING | KernelRestarter: restart failed
2014-09-14 20:53:59.866 [SingleUserNotebookApp] WARNING | Kernel ec8afdad-2a1e-47f2-8202-d3644832c13e died, removing from map.
ERROR:root:kernel ec8afdad-2a1e-47f2-8202-d3644832c13e restarted failed!

```



Discussion:
What version of IPython do you have?

I'm running ipython 2.2.0 with python 3.4.1 from anaconda dist.

Do you have an IPython config?

Yes I have, so I did a backup and remove my `.ipython` directory. Then I run the command `jupyterhub`, everything seems ok:

```
Proxying *:8000 to http://localhost:8081
Proxy API at localhost:8001/api/routes
```

Then I visit localhost:8000 and I get the log in page without error(except the favicon)

I login and cookie-name option is accepted

```
[I 09:23:26.388 tornado.access] 200 GET /hub/login (127.0.0.1) 5.34ms
[I 09:23:35.934 JupyterHubApp] Spawning ['jupyterhub-singleuser', '--user=ben', '--port=34432', '--cookie-name=jupyter-hub-token-ben', '--base-url=/user/ben', '--hub-prefix=/hub/', '--hub-api-url=http://localhost:8081/hub/api']
2014-09-16 09:23:36.234 [SingleUserNotebookApp] Created profile dir: '/media/home/ben/.ipython/profile_default'
2014-09-16 09:23:36.238 [SingleUserNotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-09-16 09:23:36.250 [SingleUserNotebookApp] Serving notebooks from local directory: /media/home/ben
2014-09-16 09:23:36.250 [SingleUserNotebookApp] 0 active kernels 
2014-09-16 09:23:36.250 [SingleUserNotebookApp] The IPython Notebook is running at: http://localhost:34432/user/ben/
2014-09-16 09:23:36.250 [SingleUserNotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 09:23:36.365 tornado.access] 302 POST /hub/login?next= (127.0.0.1) 474.53ms
[I 09:23:36.372 tornado.access] 302 GET /hub/ (127.0.0.1) 2.11ms
[I 09:23:36.390 tornado.access] 304 GET /hub/home (127.0.0.1) 12.80ms
```

The problem occurs when I open or create a notebook:

```
[IPKernelApp] CRITICAL | Bad config encountered during initialization:
[IPKernelApp] CRITICAL | Invalid argument: '--cookie-name=jupyter-hub-token-ben'
2014-09-16 09:31:04.663 [SingleUserNotebookApp] KernelRestarter: restarting kernel (3/5)
WARNING:root:kernel 67823064-4197-4b90-a262-71a61806dd09 restarted
[IPKernelApp] WARNING | Unrecognized alias: '--cookie-name=jupyter-hub-token-ben', it will probably have no effect.
IPython: an enhanced interactive Python shell.
```

Can you run `jupyterhub-singleuser` manually, and check what `IPython.sys_info()` is in that context? I suspect it's finding an old IPython.

When I run `jupyter-singleuser` manually there's no server error, but I get a blank page with only the ipython logo in the top.

```
2014-09-17 18:46:04.141 [SingleUserNotebookApp] Using existing profile dir: '/media/home/ben/.ipython/profile_default'
2014-09-17 18:46:04.206 [SingleUserNotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-09-17 18:46:04.262 [SingleUserNotebookApp] Serving notebooks from local directory: /media/home/ben/Documents/Ordi/Python/ipython/notebooks-data
2014-09-17 18:46:04.262 [SingleUserNotebookApp] 0 active kernels 
2014-09-17 18:46:04.262 [SingleUserNotebookApp] The IPython Notebook is running at: http://localhost:8888/
2014-09-17 18:46:04.262 [SingleUserNotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
INFO:tornado.access:302 GET / (127.0.0.1) 1.00ms
INFO:tornado.access:302 GET /tree/ (127.0.0.1) 0.62ms
```

I can't get my ipython version in reason of the kernels errors, however I think it's 2.x because in the tree view(after jupyterhub connection) I have the 3 Tabs(Notebooks Running Clusters    ) and opening the notebook I have the same menus  than 2.x with the user interface tour which is new in 2.x. I tried to remove anaconda from the PATH and run the dist ipython and I got the same errors.

Can you try running from master again?  What do you get from:

``` bash
$ which -a python
$ which -a ipython
$ which -a jupyterhub-singleuser
$ cat $(which jupyterhub-singleuser)
```

```
$ which -a python
/media/home/ben/.miniconda3/bin/python
/usr/bin/python

$which -a ipython
/media/home/ben/.miniconda3/bin/ipython
/usr/local/bin/ipython
```

Both ipython versions are 2.2.0

```
$ which -a jupyterhub-singleuser
/media/home/ben/.miniconda3/bin/jupyterhub-singleuser
/usr/local/bin/jupyterhub-singleuser

$ cat $(which jupyterhub-singleuser)
#!/media/home/ben/.miniconda3/bin/python3

from jupyterhub.singleuserapp import main
main()
```

When I remove miniconda from the `$PATH`, I have exactly the same problems of kernels in `jupyterhub` app and white page in `jupyterhub-singleuser`

Here's the jupyterhub-singleapp from /usr/local/bin

```
$ cat /usr/local/bin/jupyterhub-singleuser
#!/usr/bin/python

from jupyterhub.singleuserapp import main
main()
```

I tried to install jupyterhub on a fresh install of lubuntu 14.04 inside a VM, and I get into the same errors. Maybe the problem is specific to ubuntu?

What do you get from `/usr/bin/python -m IPython --version`?

```
$ /usr/bin/python -m IPython --version
2.2.0
```


Resolving patch:
diff --git a/jupyterhub/singleuserapp.py b/jupyterhub/singleuserapp.py
--- a/jupyterhub/singleuserapp.py
+++ b/jupyterhub/singleuserapp.py
@@ -94,6 +94,11 @@ def _confirm_exit(self):
         # disable the exit confirmation for background notebook processes
         ioloop.IOLoop.instance().stop()
     
+    def init_kernel_argv(self):
+        """construct the kernel arguments"""
+        # FIXME: This is 2.x-compat, remove when 3.x is requred
+        self.kernel_argv = ["--profile-dir", self.profile_dir.location]
+    
     def init_webapp(self):
         # monkeypatch authentication to use the hub
         from IPython.html.base.handlers import AuthenticatedHandler


Test patch: