Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda - Silently installing a package

I am trying to automate the process of setting up a development environment with pandas package using conda.

I installed conda, created and activated a dev environment. When I tried to install a package as follows, I noticed that there was a prompt to which a user had to key in Y or N (Proceed ([y]/n)?) for the installation to proceed successfully.

$ conda install pandas
Fetching package metadata: ....
Solving package specifications: ..................
Package plan for installation in environment /home/miniconda2/envs/pandas_env:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    libgfortran-1.0            |                0         170 KB
    openblas-0.2.14            |                3         3.5 MB
    numpy-1.10.2               |           py27_0         5.9 MB
    pytz-2015.7                |           py27_0         174 KB
    six-1.10.0                 |           py27_0          16 KB
    python-dateutil-2.4.2      |           py27_0         219 KB
    pandas-0.17.1              |      np110py27_0        12.4 MB
    ------------------------------------------------------------
                                           Total:        22.3 MB

The following NEW packages will be INSTALLED:

    libgfortran:     1.0-0             
    numpy:           1.10.2-py27_0     
    openblas:        0.2.14-3          
    pandas:          0.17.1-np110py27_0
    python-dateutil: 2.4.2-py27_0      
    pytz:            2015.7-py27_0     
    six:             1.10.0-py27_0     

Proceed ([y]/n)? y

Fetching packages ...
libgfortran-1. 100% |###################################################################################################################################################################| Time: 0:00:00 457.23 kB/s
openblas-0.2.1 100% |###################################################################################################################################################################| Time: 0:00:02   1.68 MB/s
numpy-1.10.2-p 100% |###################################################################################################################################################################| Time: 0:00:02   2.42 MB/s
pytz-2015.7-py 100% |###################################################################################################################################################################| Time: 0:00:00 388.35 kB/s
six-1.10.0-py2 100% |###################################################################################################################################################################| Time: 0:00:00 224.69 kB/s
python-dateuti 100% |###################################################################################################################################################################| Time: 0:00:00 493.15 kB/s
pandas-0.17.1- 100% |###################################################################################################################################################################| Time: 0:00:04   3.24 MB/s
Extracting packages ...
[      COMPLETE      ]|######################################################################################################################################################################################| 100%
Linking packages ...
[      COMPLETE      ]|######################################################################################################################################################################################| 100%

How can I override these prompts so that the installation takes place silently? I tried using the -f flag but it does not seem to be existing with the conda install command.

Thanks in advance!

like image 982
activelearner Avatar asked Jan 06 '16 23:01

activelearner


People also ask

Can I use pip to install packages in conda?

You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment. If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.

Can I use pip instead of conda?

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side (by installing pip with conda install pip ) but they do not interoperate either.


3 Answers

Used $conda install -y pandas and it installed without any prompts (see documentation).

like image 170
activelearner Avatar answered Oct 06 '22 17:10

activelearner


One-time Use

-y, --yes option.

# e.g. No.1
conda create -n myenv python=3.6 -y

# e.g. No.2
# install into a specific environment
conda install -n myenv requests -y
# install into the "base" env
conda install flake8 --yes

Script Use

Warning. This method confirms any type of prompt.

export CONDA_ALWAYS_YES="true"

# confirm all following "conda" commands
conda create -n myenv
conda install -n myenv requests
# ...

# Disable yes to all
unset CONDA_ALWAYS_YES 

You may need to check How to activate conda env through shell script.


Environment Specific Use

Warning. This method confirms any type of prompt.

Enable "yes" to any prompt within current active env.

# enable yes to all in current env
conda config --env --set always_yes true

# disable it in current env
conda config --env --remove always_yes
like image 38
Simba Avatar answered Oct 06 '22 17:10

Simba


I suggest not to pass the confirmation process.

because it always has important info regarding this installation(which package will be updated and which dependency package will be installed and which package will be downgraded)

I once corrupt my environment due to not notice the update some of the package and took a long time to figure out some package need to stay in a older version to make some other package run properly.And that confirmation details will always makes you informed and tell you where to debug once you corrupt your package environment after installation

Anyway, here is the solution. Just use -y flag :

conda install -y PACKAGE_NAME
like image 3
cloudscomputes Avatar answered Oct 06 '22 16:10

cloudscomputes