简体   繁体   中英

How to set environment variables in DataSpell and access them in a Jupyter notebook?

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.

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).

You can find the details about how to create environment variable using DataSpell here .

在此处输入图像描述

Like this image, on the bottom right corner of your DataSpell, you see the environment variable. If you click it, you will also see the list of the loaded projects and corresponding environment variables there.

You can change your environment variable for the specific project from here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM