我正在创建一个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
更多推荐
发布评论