3

I'm super new to programming, i'm trying to learn how to create a project, make venv, and activate it.

Question 1: do i have to activate the conda env every time i open command prompt?

If i open cmd and type in "python" i get this message:

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.
>>>     

I type in "conda activate" and everything is cool and good. If i close cmd and open it again, it acts as if I never activated conda and gives me the same message again. Is this normal? Do i have to activate the conda env every time?

Question 2: what's the difference between (base), (env), and (base) (env) and why does the following happen?

I followed a tutorial for making a python project, making an env in command prompt, and activating it with "env\Scripts\activate.bat" and got the (env) output. Then i closed cmd, opened it again, and if i navigate to the path where my example env lives, it doesn't say (env) in front of it.

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.
>>>                                                                                                               

I'm sorry that this is really basic. After trying to research this for 2 days i'm kind of lost. I'm at the level where I'm struggling with step 0 of starting a project. Am I supposed to activate whatever env i need every time I open command prompt? Am i supposed to activate venv every time i want to work on the project even if I don't open cmd? Is the fact that my venv doesn't stay activated a problem? What dies (base) mean?

ellie-lumen
  • 197
  • 2
  • 9
  • 1
    ...why would you expect any virtualenv to be activated automatically? It's a _project-speecific environment_. – ChrisGPT was on strike Apr 12 '20 at 23:46
  • if you use pycharm ide and configure your virtualenv with the project then the ide terminal it will come automatically – sahasrara62 Apr 12 '20 at 23:47
  • _what's the difference between (base), (env), and (base) (env)_ It looks like you're mixing/combining Conda and venv, might that be the case? Have you read the [Conda docs](https://docs.conda.io/en/latest/) ? I agree with @sahasrara62 that perhaps you should let your IDE handle the more tedious parts of the process, although I would recommend Conda over venv. – AMC Apr 13 '20 at 00:36

1 Answers1

3

Environments are an important part of Python, especially if you're working on multiple projects with separate dependencies.

...For example if project_a uses Python 2.7, but project_b uses Python 3.6 you would want two separate environments or you're guaranteed to have dependencies issues and an immense headache.

Question 1: do i have to activate the conda env every time i open command prompt?

No, you do not have to activate conda every time you open CMD. This is simply a matter of choice for the developer. That being said, if you are working on a Windows machine and exclusively using a singular Conda environment, you might find it easier to start the Anaconda Terminal rather than starting CMD and having to activate your environment everytime.

If you are frequently switching between environments, than you'll likely be better off starting and stopping you Conda or Python Environments from CMD...again matter of choice.

Question 2: what's the difference between (base), (env), and (base) (env) and why does the following happen?

What you have here are two different environments. Where I assume that base is a Conda Environment and env is a Python Virtual Environment.

If you wish to know more about more about the difference between the two, the following article may be a good place to start https://www.anaconda.com/understanding-conda-and-pip/

Landon L
  • 138
  • 4
  • _If you wish to know more about more about the difference between the two, the following article may be a good place to start https://www.anaconda.com/understanding-conda-and-pip/_ That's about Conda and Pip though, not Conda and venv. – AMC Apr 13 '20 at 00:43