anconda 配置环境激活时的变量

anconda 配置环境激活时的变量,第1张

anconda 配置环境激活时的变量

    Locate the directory for the conda environment in your terminal window by running in the terminal 

echo $CONDA_PREFIX.

    Enter that directory and create these subdirectories and files:

cd $CONDA_PREFIX
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
touch ./etc/conda/activate.d/env_vars.sh
touch ./etc/conda/deactivate.d/env_vars.sh

    Edit ./etc/conda/activate.d/env_vars.sh as follows:

#!/bin/sh

export MY_KEY='secret-key-value'
export MY_FILE=/path/to/my/file/

    Edit ./etc/conda/deactivate.d/env_vars.sh as follows:

#!/bin/sh

unset MY_KEY
unset MY_FILE

When you run conda activate analytics, the environment variables MY_KEY and MY_FILE are set to the values you wrote into the file. When you run conda deactivate, those variables are erased.

参考链接:Managing environments — conda 4.11.0.post20+db4e1c0f2 documentationhttps://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#saving-environment-variables

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5720495.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存