19

enter image description here

I'm trying to create a conda environment using git-bash and win10. I ran:

$ conda create --name my_env

The result looks like the screenshot above.

Looking at other environments , I can see they normally look like:

enter image description here

How can I fix this?

Asclepius
  • 57,944
  • 17
  • 167
  • 143
user1592380
  • 34,265
  • 92
  • 284
  • 515

3 Answers3

51

To create the environment with the Python executable, use one of:

conda create --name my_env python  # latest available python version
conda create --name my_env python=3.7  # specific python version

Without specifying packages, i.e. python as above, conda just doesn't install anything at all in my_env environment.


You can alternatively install the Python interpreter after environment creation. For a list of installable Python versions, run conda search "^python$".

conda install python  # latest available python version
conda install python=3.7  # specific python version
Asclepius
  • 57,944
  • 17
  • 167
  • 143
pkowalczyk
  • 16,763
  • 6
  • 27
  • 35
  • 2
    I'd just note that prior to Conda v4.4, Conda used to leave the **base** env on PATH, which is why previously people may have had experiences where not specifying `python` or `anaconda` explicitly still led to a Python on the PATH. But yeah, now the envs are totally isolated and hence `python` must be specified. – merv Feb 16 '21 at 03:48
  • 1
    @merv thanks for the clarification. I've recently upgraded to the latest version of conda and got very confused when it didn't install anything in it. At this point my question is: what's the point of not installing even the base packages? – wtfzambo Apr 27 '21 at 14:29
  • @wtfzambo I'd counter with: what's a "*base package*"? I liberally create environments and the intersection across all them is the empty set, hence I'd argue there is no such thing as a "base package" for all users. I think a big part of this is that Conda is a generalized package manager - not just Python - so envs can vary widely in what is installed. However, note that you are free to define your own custom default packages (see [docs](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#adding-default-packages-to-new-environments-automatically)). – merv Apr 27 '21 at 15:55
  • @merv fair enough you got a point, with base packages I meant the ones that would get installed if I ran `conda create -n myenv python`. To rephrase, I was expecting `conda create -n myenv` behavior to default to the former command behavior. Also because creating an virtual env without any python executable in it doesn't make much sense anyway, does it ? – wtfzambo Apr 27 '21 at 15:57
  • @wtfzambo perhaps not if one is equating "*virtual env*" with "Python virtual env", but I think it is sensible for multi-lingual users. For example, I have many envs without `python` - some just have R, C++, an IDE (e.g., emacs), or some bioinformatics tools for particular pipelines. Also, note that Conda never installed `python` by default - rather it simply used to leave the **base** environment's `bin/` directory on `PATH` and that happened to include a Python interpreter, since `conda` itself is mainly written in Python. – merv Apr 27 '21 at 16:24
  • 1
    @merv ahhh, I see my mistake now! Being a python dev only I used conda exclusively to do data-sciency stuff, and therefore didn't know / consider that it can be used as a package manager for many other things. – wtfzambo Apr 27 '21 at 16:47
6

You have to use this to get all of the Anaconda default packages:

conda create --name my_env anaconda

Otherwise, it doesn't install everything.

gaw89
  • 1,018
  • 9
  • 19
  • 2
    I'm actually using Miniconda, and don't want all the packages, but in my case it doesn't even create a copy of the python interpreter (i.e. python.exe) – user1592380 Mar 31 '17 at 20:27
  • Oh, sorry. Couldn't actually see the screenshots at work. What if you use Windows CMD instead of git-bash? – gaw89 Mar 31 '17 at 20:37
  • I used Anaconda Prompt and I got the same problem! – Elias Oct 03 '19 at 15:12
  • Worked like a charm. Using the above answer did not install all of the conda packages like pandas. However, your answer solved my problem using WIN10 CMD. Thank you. – ShayHa Sep 11 '20 at 14:38
  • Which version of python is installed when using the above code? The python version of the latest release of Anaconda from [here](https://docs.anaconda.com/anaconda/packages/pkg-docs/)? – mouwsy Mar 16 '21 at 10:37
  • I believe it is whatever version is the default for the Anaconda version you install. E.g. if you install the Python 3.8 version it will be Python 3.8 or if you install the 3.7 version it will be 3.7. You can also specify the version of Python by adding `python=[VERSION_NUM]` at the end of the above command. – gaw89 Mar 16 '21 at 21:36
-1

Everytime you set up a new venv with conda and want to have the python.exe file on the new venv you must run the following script:

conda install pip

Then just follow the indications and that's it!.

Dharman
  • 30,962
  • 25
  • 85
  • 135