Search code examples
windowscmdanacondavirtualenvconda

Silently create conda virtual environment in Windows 10


Is it possible to silently create a conda virtual environment for Python version 3.6.8 in Windows 10, from an anaconda (cmd) prompt, using either of these commands modified? (or any other way):

conda create -n py368 Python=3.6.8 /S

conda create -n py368 Python=3.6.8 /Q

call conda create -n py368 Python=3.6.8 /S

call conda create -n py368 Python=3.6.8 /Q

Upon running either of the above commands, Anaconda seem to read /S or /Q as a missing package, instead of the silent keyword.


Solution

  • You are using Windows syntax for a program that is fundamentally a Linux-based application that has been ported to Windows. Rather than using a /S, you need to use either -y or --yes.

    Also, the package specification must come at the end of the command line. So, the syntax that you are looking for is something like the following.

    conda create -n py368 --yes Python=3.6.8
    

    or, if you don't want to see any output,

    conda create -n py368 --yes Python=3.6.8 2> $null > $null
    

    Warning, in some versions of conda, such as conda 3.7.3, and possible conda 3.7.2, the auto-accept command option (-y/--yes) was ignored, and the examples above would hang while waiting for user-input. In the broken versions of conda, the following example also doesn't work:

    echo y | conda create -n py368 --yes Python=3.6.8
    
    

    Workaround: This has worked in all versions of conda that I have tested it in.

    conda config --set always_yes True
    conda create -n py368 --yes Python=3.6.8