5

I do conda create --name env then conda activate env.

My prompt now has (env) at the beginning of it. Then I try running python at the prompt and it returns

'python' is not recognized as an internal or external command, operable program or batch file.

The documentation explicitly states

This environment uses the same version of Python that you are currently using because you did not specify a version.

However, if I do conda create --name env python=3.8, my environment correctly runs python 3.8. It seems like if I don't specify a version, my environment is completely empty (which it is when I look in the directory). But the documentation says that it should have the version of python from the base. What am I doing wrong?

I'm using an anaconda prompt in Windows 10.

fiziks
  • 247
  • 2
  • 5
  • 2
    You're not doing anything wrong, this is just how conda works. The documentation is probably a little bit unclear... what it means is that if you specify a package that depends on Python (but is not itself Python), say, NumPy, then the Python version used to satisfy the dependency will be the same as the current environment. – darthbith Feb 18 '20 at 23:37
  • I was not able to reproduce on my machine. When creating an empty environment and activating it, `python` still points to `C:\ProgramData\Miniconda3\python.exe`. Which version of conda are you using? Can you add the output of `echo %PATH%` before and after activating `env` to your question? – FlyingTeller Feb 19 '20 at 09:56

1 Answers1

3

I think that bit of documentation is outdated and is a hold-over from pre-v4.4, when the recommended practice was to put the base env's bin/ directory on PATH. In Conda v4.4+, the base env is no longer accessible by default when another env is activated.

To have Python in an env, one must explicitly request it to be installed, e.g.,

conda create --name env python

Note, one doesn't have to specify a version.

In the end, this should be seen as an advantage, since it allows users to create non-Python envs and keeps the base env isolated.

merv
  • 67,214
  • 13
  • 180
  • 245