Skip to content
Snippets Groups Projects

Pyenv kernel tutorial

Merged Filipe Guimaraes requested to merge guimaraes1/j4j_notebooks:master into master
3 unresolved threads

Created tutorial for creation of Jupyter kernel using pyenv.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
34 "cell_type": "markdown",
35 "metadata": {},
36 "source": [
37 "## Building your own Jupyter pyenv-kernel is a four-step process\n",
38 "\n",
39 "1. **[Download/Install pyenv](#install)**: To start from scratch, and run the full installation.\n",
40 "2. **[Create and setup environment](#environment)**: To create an(other) environment in an existing pyenv setup.\n",
41 "3. **[Create/Edit launch script for the Jupyter kernel](#kernel)**: To setup an environment to be run via Jupyter.\n",
42 "4. **[Create/Edit Jupyter kernel configuration](#json)**: To attach your user to an existing environment via Jupyter. "
43 ]
44 },
45 {
46 "cell_type": "markdown",
47 "metadata": {},
48 "source": [
49 "If `pyenv` is already installed, start at 2.\n",
  • 84 ]
    85 },
    86 {
    87 "cell_type": "markdown",
    88 "metadata": {},
    89 "source": [
    90 "Also the environment name can be set in an environment variable **PYENV_ENV** to simplify the process:"
    91 ]
    92 },
    93 {
    94 "cell_type": "code",
    95 "execution_count": null,
    96 "metadata": {},
    97 "outputs": [],
    98 "source": [
    99 "export PYENV_ENV=my_env"
    • .bash_profile is executed for login shells. Do you think it is a good idea to recommend a user to always initialize pyenv when they ssh to a login-shell. :thinking:
      I could create a script like $HOME/pyenv_init.sh which has to be sourced when the user wants to use pyenv. This ensures that they can use our modules always after login by default.

    • Indeed, this is the part I mentioned to you that it was not clear to me. I actually use that only for the process, but I deleted those lines later on (since I added them to the kernel.sh). I will test if they are needed at this step at all (at some point, I didn't put it - but I had ran them - and I couldn't activate the environment).

    • Users tend to add line like that and will leave them there. A few days later they try to load some module and it fails.
      I would not risk it - it will for sure end up in a support ticket later on.

    • Yes, I also agree with that. I wanted to make a "working version" before improving it. This was the main issue now, and I need to see how I can avoid changing the ~/.bash_profile keeping everything working.

    • Filipe Guimaraes changed this line in version 2 of the diff

      changed this line in version 2 of the diff

    • Please register or sign in to reply
  • 251 {
    252 "cell_type": "code",
    253 "execution_count": null,
    254 "metadata": {},
    255 "outputs": [],
    256 "source": [
    257 "pyenv activate $PYENV_ENV"
    258 ]
    259 },
    260 {
    261 "cell_type": "markdown",
    262 "metadata": {},
    263 "source": [
    264 "When the environment is successfully activated, the name of the environment is shown between parenthesis in the command line, e.g. `(my_env)`. (To deactivate the environment, use `pyenv deactivate $PYENV_ENV`.)"
    265 ]
    266 },
    • $PYENV_ENV is not set in kernel.sh. This means that the correct functionality of kernel.sh depends on something else (.bashrc ? .. oh, no :) ).
      What if a user wants to have multiple pyenv-environments for different Python versions or some other fancy reason.
      I would recommend to set PYENV_ENV in kernel.sh, too.

      Edited by Jens Henrik Goebbert
    • That's only to create the file, if the user is copying and pasting the lines. The idea is exactly that: if the user wants different versions, he'll just change PYENV_ENV and run the same command again (and that's why it is not exported there).

    • Ah, ok. That makes sense.

    • Please register or sign in to reply
  • added 1 commit

    • 8d2555eb - pyenv kernel tutorial: Removed any mention to changes in .bash_profile;...

    Compare with previous version

  • Jens Henrik Goebbert approved this merge request

    approved this merge request

  • mentioned in commit 8c6f35d5

  • Please register or sign in to reply
    Loading