Giter Club home page Giter Club logo

Comments (5)

Frank-Steiner avatar Frank-Steiner commented on July 18, 2024 1

Ok, here's how to solve it (should be documented somewhere in the sudospawner webpage I guess):

  1. to make the neccessary variables be passed to sudospawner, use
    Defaults env_keep += "PYTHONPATH JUPYTER_PATH WHATEVER_ELSE"
    in the sudoers file.
  2. Now sudospawner will start, but mediator removes the PYTHONPATH variable, so we run into the same problem just one step later
Feb 09 17:44:09 myhost start_jhub[8254]: [I 230209 17:44:09 mediator:89] Spawning /opt/jhub/bin/jupyterhub-singleuser
Feb 09 17:44:09 myhost start_jhub[8254]: [W 230209 17:44:09 mediator:91] PYTHONPATH env not allowed for security reasons
Feb 09 17:44:09 myhost start_jhub[8254]: Traceback (most recent call last):
Feb 09 17:44:09 myhost start_jhub[8254]:   File "/opt/jhub/bin/jupyterhub-singleuser", line 5, in <module>
Feb 09 17:44:09 myhost start_jhub[8254]:     from jupyterhub.singleuser import main
Feb 09 17:44:09 myhost start_jhub[8254]: ModuleNotFoundError: No module named 'jupyterhub'

According to https://github.com/jupyterhub/sudospawner we can solve this by creating a file sudospawner-singleuser. This will be called from sudospawner instead of jupyterhub-singleuser, so we can set PYTHONPATH again and then call jupyterhub-singleuser ourself:

#!/bin/bash 

export PYTHONPATH=<set your path>
exec "$(dirname "$0")/jupyterhub-singleuser" $@

And now it works.

from sudospawner.

welcome avatar welcome commented on July 18, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

from sudospawner.

welcome avatar welcome commented on July 18, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

from sudospawner.

Frank-Steiner avatar Frank-Steiner commented on July 18, 2024

Having exactly the same problem. sudospawner fails to start as the neccessary PYTHONPATH variable get's lost despite c.Spawner.env_keep is listing it.

from sudospawner.

jelmd avatar jelmd commented on July 18, 2024

The problem is, that you do not pass PYTHONPATH but set it to a new, possibly unexpected value ...

Therefore I use the following workaround in our cluster:

export JUPYTER_PATH=/usr/local/jupyter
#...
    sed -i.orig -e "/self.sudo_args/ a\        if 'PYTHONPATH' in os.environ:\n            cmd.append('='.join(['PYTHONPATH', os.environ['PYTHONPATH']]))" \
        ${JUPYTER_PATH}/lib/python${PY_VERS}/site-packages/sudospawner/spawner.py
    sed -i.orig -e "/if'PYTHONPATH' in env:/ s/:/ and 'NO_PYTHONPATH' in env:/"\
        ${JUPYTER_PATH}/lib/python${PY_VERS}/site-packages/sudospawner/mediator.py
#...
    if [[ ! -e /usr/local/jupyter/bin/jupyterhub-singleuser ]]; then
        print '#!/bin/bash -l

unset HTTP_PROXY HTTPS_PROXY
if [[ -z ${PY_VERSION} ]]; then
    case "$( lsb_release -rs )" in
        20.04) export PY_VERSION=3.8 ;;
        18.04) export PY_VERSION=3.6 ;;
    esac
fi

PYTHONPATH="${PYTHONPATH}:/usr/local/jupyter/lib/python${PY_VERSION}/site-packages"
exec /usr/local/jupyter/bin/jupyterhub-singleuser "$@"
'           >/usr/local/jupyter/bin/jupyterhub-singleuser
    fi

Have fun ;-)

from sudospawner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.