在Conda中创建一个激活后脚本(Create a post activate script in Conda)

编程入门 行业动态 更新时间:2024-10-25 21:29:36
在Conda中创建一个激活后脚本(Create a post activate script in Conda)

我正在创建一个Django Web应用程序,并使用Conda来管理所需的软件包和虚拟环境。 我想在激活环境后立即设置环境变量(Django设置位置)。 它还应该将当前目录更改为我的项目目录。

我以前使用过virtualenvwrapper,我只是将这些命令添加到postactivate脚本中。

如何使用Conda实现这一目标?

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.

I previously used virtualenvwrapper and I just added the commands to the postactivate script.

How can I achieve this using Conda?

最满意答案

从conda v3.8开始,这个功能就已经可用了(在提出这个问题之后)。 放置在${CONDA_PREFIX}/etc/conda/activate.d/任何*.sh文件将在环境激活时获取。

文档: 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

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.

Docs: https://conda.io/docs/user-guide/tasks/manage-environments.html#saving-environment-variables

Also explained here: https://groups.google.com/a/continuum.io/d/msg/anaconda/sQJQ7DBwpfI/pP4_Esbl6VYJ

更多推荐

本文发布于:2023-08-07 18:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:创建一个   脚本   Conda   Create   script

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!