4

In JetBrains PyCharm, runtime environment variables can be set from Run > Edit Configurations. However, in JetBrains DataSpell, I can't find the Run Configurations menu option. I can add env vars for Terminal or Console from the Preferences menu, but these are not loaded when running a Jupyter notebook.

The DataSpell documentation indicates that this might be possible, but I still don't see the run configs option. The prerequisites require that "Python plugin is installed and enabled", but I don't see any plugin called "Python" in the JetBrains plugin marketplace.

How can I configure env vars in DataSpell that are accessible when running cells in a Jupyter notebook? (I would rather NOT set up these vars in the OS).

EDIT: After I messaged JetBrains, references to the "Python plugin" were removed from the documentation. I also upgraded to 2022.1 EAP and there is still no Run Configurations option.

DV82XL
  • 5,350
  • 5
  • 30
  • 59

1 Answers1

1

As of the time of this writing, it seems there is no possibility to configure the environment variable from within the IDE. However, you can always use the %env magic command inside your notebook cells:

%env VARIABLE=VALUE

This way you will have custom variables per notebook and they will be only available from the scope of the notebook itself (not the OS).

Manuel Montoya
  • 1,206
  • 13
  • 25
  • 1
    Decent option. The problem with this is that if the env var contains sensitive information, it would be bad practice to put it in clear text in the notebook or, even worse, commit it to git. – DV82XL Apr 07 '22 at 15:18
  • Good catch. Maybe you could try the kernel solution proposed [here](https://stackoverflow.com/questions/37890898/how-to-set-env-variable-in-jupyter-notebook) – Manuel Montoya Apr 07 '22 at 21:39