gpt4 book ai didi

python - 为什么我每次打开 cmd 都需要激活 conda 和我的 venv?这是正常的吗?

转载 作者:行者123 更新时间:2023-12-04 10:13:48 27 4
gpt4 key购买 nike

<分区>

我是编程新手,我正在尝试学习如何创建项目、制作 venv 并激活它。

问题一:每次打开命令提示符都要激活conda env吗?

如果我打开 cmd 并输入“python”,我会收到此消息:

Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>>

我输入“conda activate”,一切都很好。如果我关闭 cmd 并再次打开它,它就好像我从未激活过 conda 并再次给我相同的消息。这是正常的吗?我每次都必须激活 conda env 吗?

问题 2:(base)、(env) 和 (base) (env) 之间有什么区别,为什么会出现以下情况?

我按照教程制作了一个 python 项目,在命令提示符下制作了一个 env,并使用“env\Scripts\activate.bat”激活它并获得了 (env) 输出。然后我关闭 cmd,再次打开它,如果我导航到我的示例 env 所在的路径,它不会在它前面说 (env)。

D:\>cd D:/Favorites/1. Programming/LearnPython/PracticeProject

D:\Favorites\1. Programming\LearnPython\PracticeProject>python
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

D:\Favorites\1. Programming\LearnPython\PracticeProject>env\Scripts\activate.bat

(env) D:\Favorites\1. Programming\LearnPython\PracticeProject>python
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

(env) D:\Favorites\1. Programming\LearnPython\PracticeProject>conda activate

(base) (env) D:\Favorites\1. Programming\LearnPython\PracticeProject>python
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

很抱歉,这真的很基础。在尝试对此进行研究 2 天后,我有点迷路了。我正处于为开始项目的第 0 步而苦苦挣扎的水平。我是否应该在每次打开命令提示符时激活我需要的任何环境?即使我不打开 cmd,我是否应该在每次我想处理该项目时激活 venv?我的 venv 没有保持激活状态是个问题吗? dies(base)是什么意思?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com