Permission denied with pyenv virtualenv kernel

Hi! I’m running the docker jupyterhub with 3 users. I would like to have a custom pyenv virtualenv for each one of the users. I’ve followed this blog to create a virtual env from pyenv python 3.7.1. However, when I try to select my kernel inside jupyterlab I got the following error in the docker log:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/tornado/web.py", line 1704, in _execute
        result = await result
      File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 769, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "/usr/local/lib/python3.8/dist-packages/notebook/services/sessions/handlers.py", line 69, in post
        model = yield maybe_future(
      File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 762, in run
        value = future.result()
      File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 769, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "/usr/local/lib/python3.8/dist-packages/notebook/services/sessions/sessionmanager.py", line 98, in create_session
        kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
      File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 762, in run
        value = future.result()
      File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 769, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "/usr/local/lib/python3.8/dist-packages/notebook/services/sessions/sessionmanager.py", line 110, in start_kernel_for_session
        kernel_id = yield maybe_future(
      File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 762, in run
        value = future.result()
      File "/usr/local/lib/python3.8/dist-packages/notebook/services/kernels/kernelmanager.py", line 176, in start_kernel
        kernel_id = await maybe_future(self.pinned_superclass.start_kernel(self, **kwargs))
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/utils.py", line 26, in wrapped
        raise e
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/utils.py", line 23, in wrapped
        return loop.run_until_complete(future)
      File "/usr/local/lib/python3.8/dist-packages/nest_asyncio.py", line 70, in run_until_complete
        return f.result()
      File "/usr/lib/python3.8/asyncio/futures.py", line 178, in result
        raise self._exception
      File "/usr/lib/python3.8/asyncio/tasks.py", line 280, in __step
        result = coro.send(None)
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/multikernelmanager.py", line 186, in _async_start_kernel
        self._add_kernel_when_ready(kernel_id, km, ensure_async(km.start_kernel(**kwargs)))
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/utils.py", line 26, in wrapped
        raise e
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/utils.py", line 23, in wrapped
        return loop.run_until_complete(future)
      File "/usr/local/lib/python3.8/dist-packages/nest_asyncio.py", line 70, in run_until_complete
        return f.result()
      File "/usr/lib/python3.8/asyncio/futures.py", line 178, in result
        raise self._exception
      File "/usr/lib/python3.8/asyncio/tasks.py", line 280, in __step
        result = coro.send(None)
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/manager.py", line 336, in _async_start_kernel
        await ensure_async(self._launch_kernel(kernel_cmd, **kw))
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/utils.py", line 26, in wrapped
        raise e
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/utils.py", line 23, in wrapped
        return loop.run_until_complete(future)
      File "/usr/local/lib/python3.8/dist-packages/nest_asyncio.py", line 70, in run_until_complete
        return f.result()
      File "/usr/lib/python3.8/asyncio/futures.py", line 178, in result
        raise self._exception
      File "/usr/lib/python3.8/asyncio/tasks.py", line 280, in __step
        result = coro.send(None)
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/manager.py", line 257, in _async_launch_kernel
        connection_info = await self.provisioner.launch_kernel(kernel_cmd, **kw)
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/provisioning/local_provisioner.py", line 179, in launch_kernel
        self.process = launch_kernel(cmd, **scrubbed_kwargs)
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/launcher.py", line 169, in launch_kernel
        raise ex
      File "/usr/local/lib/python3.8/dist-packages/jupyter_client/launcher.py", line 157, in launch_kernel
        proc = Popen(cmd, **kwargs)
      File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    PermissionError: [Errno 13] Permission denied: '/root/.pyenv/versions/myenv/bin/python'

I tried to give others permissions to the files and also move the .pyenv folder in other place but nothing seems to work. Any idea ?

Hi! Please could you explain what you mean by “docker jupyterhub”- are you using JupyterHub to spin up singleuser servers with DockerSpawner, or something else? It would be helpful if you could give us full details of your deployment, including configuration.