同时激活VENV和CONDA环境

发布于 2025-02-03 18:37:58 字数 392 浏览 4 评论 0原文

我是一个初学者,并且在环境中“玩耍”。我遇到了一个情况,似乎我已经激活了两个环境: 我创建一个目录,使用VENV创建环境,激活它,然后Conda激活我之前创建的Conda环境。这些是命令:

mkdir dummie_directory
cd dummie_directory
python -m venv .
Scripts\activate
conda activate old_env

在此之后,我的命令行的开头看起来像这样:

(old_env)(dummie_directory) C:\Users\....

这是否意味着两个环境都处于活动状态? 是否有任何预期用途,或者很可能会导致安装软件包之间的某种冲突/冲突?

谢谢

I am a beginner and was "playing around" with environments a bit. I came across a situation where it seemed that I had two environments activated:
I create a directory, create an environment with venv, activate it and then also conda activate a conda environment which I created before. These are the commands:

mkdir dummie_directory
cd dummie_directory
python -m venv .
Scripts\activate
conda activate old_env

After this the beginning of my command line looks like this:

(old_env)(dummie_directory) C:\Users\....

Does this mean that both environments are active?
Is there any intended use for this or will it most likely lead to some kind of clash/conflict between the installed packages?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花心好男孩 2025-02-10 18:37:59

不,这并不意味着它们都被激活。只有一个人可以在路径中优先,这是我认为“激活”在功能上含义的最简单定义。 PS1字符串中的指示器(即,Shell的提示字符串)无法牢固管理。两位环境经理只是彼此之间没有意识,并且仅当激活停用过程时才能操纵字符串。没有任何动态监控,即特定的环境仍保持活跃。

我不会依靠您在这种状态下观察到的任何行为。它没有定义的规范,也不打算这样使用。

No, it does not mean they are both activated. Only one can have priority in the PATH, which is what I’d consider the simplest definition of what “activated” means, functionally. The indicators in the PS1 string (i.e., the shell’s prompt string) are not robustly managed. The two environment managers are simply unaware of each other, and the string is only manipulated when an activate or deactivate procedure is called. There isn’t any dynamic monitoring that a particular environment is remaining active.

I wouldn’t rely on any behavior you observe in this state. It does not have a defined specification and is not intended to be used like this.

回首观望 2025-02-10 18:37:59

我要补充说,仅激活最后一个环境所带来的唯一区别是,当最后一个环境停用时,第一个环境再次重新激活。因此,它使用第一届逻辑来激活环境。

I would add that the only difference it makes from just activating the last environment is that when the last environment is deactivated the first one is again reactivated. So, it uses a first-in-first-out logic to activate environments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文