在Conda中创建后期激活脚本 [英] Create a post activate script in Conda
问题描述
我正在创建Django网络应用,并使用Conda来管理所需的程序包和虚拟环境。我想在激活环境后立即设置环境变量(Django设置位置)。它还应该将当前目录更改为我的项目目录。
I'm creating a Django web app and using Conda to manage the required packages and virtual environment. I want to set an environmental variable (the Django settings location) as soon as I activate the environment. It should also change the current directory to my project directory.
我以前使用过virtualenvwrapper,我只是将命令添加到了postactivate脚本中。
I previously used virtualenvwrapper and I just added the commands to the postactivate script.
如何实现这一目标使用Conda吗?
How can I achieve this using Conda?
推荐答案
该功能自conda v3.8开始问世(问了这个问题之后)。放置在 $ {CONDA_PREFIX} /etc/conda/activate.d /
中的任何 *。sh
文件
That feature has been available since conda v3.8 (after this question was asked). Any *.sh
files placed in ${CONDA_PREFIX}/etc/conda/activate.d/
will be sourced when the environment is activated.
文档:
https://conda.io/docs/user-guide/tasks/manage-environments.html#saving-environment-variables
也在此处解释: https://groups.google.com/a/continuum.io/d/msg/anaconda/sQJQ7DBwpfI/pP4_Esbl6VYJ
这篇关于在Conda中创建后期激活脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!