Is it feasible to launch a single user server using a conda environment's 
notebook version with something like LocalProcessSpawner? The API doc for 
LocalProcessSpawner's cmd option says:

This is usually set if you want to start the single-user server in a 
> different python environment (with virtualenv/conda) than JupyterHub itself.
>

Does anyone know of an example of doing this? I tried activating the conda 
environment and then running jupyterhub-singleuser, e.g.:

from jupyterhub.spawner import LocalProcessSpawner
c.LocalProcessSpawner.options_form = \
"""
Choose an environment:
<select name="env" multiple="true">
  <option value="default">Default</option>
  <option value="alternate">Alternate</option>
</select>
"""

def activate_env(spawner):
    env = spawner.user_options.get('env')[0]
    if env == 'alternate':
        spawner.cmd = [
            'bash', '-c',
            'source activate alternate && jupyterhub-singleuser'
        ]

c.LocalProcessSpawner.pre_spawn_hook = activate_env
import subprocess
c.LocalProcessSpawner.popen_kwargs = dict(stdout=subprocess.PIPE)
c.JupyterHub.spawner_class = LocalProcessSpawner


but the single-user server fails and I see this:

[C 2017-11-27 13:39:01.834 SingleUserNotebookApp application:90] Bad config 
encountered during initialization:
[C 2017-11-27 13:39:01.834 SingleUserNotebookApp application:91] The 'ip' 
trait of a SingleUserNotebookApp instance must be a unicode string, but a 
value of None <class 'NoneType'> was specified.

Choosing the "Default" option in the form works. This makes me think 
possibly JupyterHub's SingleUserNotebookApp isn't fully compatible with 
notebook 4.* or something. I could also easily be doing something wrong.

On Tuesday, November 21, 2017 at 5:51:45 PM UTC-8, Ryan Lovett wrote:
>
> One possible solution would be to containerize your 2014 and post-2014 
> environments, and configure your JupyterHub to use a container-based 
> spawner.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/dba77005-35b9-44e8-825f-586a45d1f454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to