4

What is the difference between conda install and conda update? I've skimmed through the documentation and I don't see any obvious difference.


The documentation says:

From conda install:

Conda attempts to install the newest versions of the requested packages. To accomplish this, it may update some packages that are already installed, or install additional packages. To prevent existing packages from updating, use the --no-update-deps option. This may force conda to install older versions of the requested packages, and it does not prevent additional dependency packages from being installed.

From conda update:

Conda attempts to install the newest versions of the requested packages. To accomplish this, it may update some packages that are already installed, or install additional packages. To prevent existing packages from updating, use the --no-update-deps option. This may force conda to install older versions of the requested packages, and it does not prevent additional dependency packages from being installed.

E_net4
  • 27,810
  • 13
  • 101
  • 139
Jason S
  • 184,598
  • 164
  • 608
  • 970
  • 3
    `install` installs a new package, `update` updates a previously installed package to the newest version, no? – DYZ Sep 07 '18 at 17:11
  • Both mention they will update to the latest version. – Jason S Sep 07 '18 at 17:28
  • 3
    But the precondition is different. `update` expects that the package is already installed. If it is not, `update` fails. Your first execute `install` (once) and then `update` (as many times as needed). – DYZ Sep 07 '18 at 17:30
  • Ah..... ok, that's the difference. – Jason S Sep 07 '18 at 17:32
  • Funny, the documentation for `update` doesn't say anything about that. (I tried it and you're right, I get a `PackageNotInstalledError` if I try to update a package that isn't installed.) I guess they depend on the dictionary-meaning implications of `install` and `update` without explicitly stating the behavior. – Jason S Sep 07 '18 at 17:36

2 Answers2

4

It's exactly what the documentation you provided says. For conda install:

Installs a list of packages into a specified conda environment.

and for conda update:

Updates conda packages to the latest compatible version.

4

In the context of the text from the documentation that was cited in the question

... Conda attempts to install the newest versions of the requested packages....

it seems important to stress that the documentation is not perfectly clear about the difference between install and update. The fact that the documentation shares the same explanation about what is installed without clarifying the conditions is certainly a bit confusing (at least to me).

The implicit distinction between installing and updating is not only that you get an error if you try to update a package that does not exist (what was mentioned in the comments to the question), but also that the side-effects (handling of dependencies) are different for install and update .

A real world example:

(base)  535> conda install -d sphinx
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /data/anaconda3

  added / updated specs:
    - sphinx


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    sphinx-3.0.3               |             py_0         1.1 MB
    ------------------------------------------------------------
                                           Total:         1.1 MB

The following packages will be UPDATED:

  sphinx                                         2.4.0-py_0 --> 3.0.3-py_0

while updating leads to

(base)  536> conda update -d sphinx
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /data/anasynth_nonbp/anaconda3

  added / updated specs:
    - sphinx


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    astroid-2.4.1              |           py36_0         279 KB
...
    sphinx-3.0.3               |             py_0         1.1 MB
...
    zipp-3.1.0                 |             py_0          13 KB
    ------------------------------------------------------------
                                           Total:        39.8 MB

The following NEW packages will be INSTALLED:

  importlib-metadata pkgs/main/linux-64::importlib-metadata-1.6.0-py36_0
  prompt-toolkit     pkgs/main/noarch::prompt-toolkit-3.0.4-py_0
  toml               pkgs/main/linux-64::toml-0.10.0-py36h28b3542_0

The following packages will be REMOVED:

  asn1crypto-1.3.0-py36_0

The following packages will be UPDATED:

  astroid                                      2.3.3-py36_0 --> 2.4.1-py36_0
...
  sphinx                                         2.4.0-py_0 --> 3.0.3-py_0
...
  zipp                                           2.2.0-py_0 --> 3.1.0-py_0

Without having investigated this into the last details it seems one can summarize as follows (last tested with conda 4.8.3):

conda install

installs the newest version of the requested package with minimal changes to the installed packages.

conda update

will update to the most recent version if the package exists and will give an error if not. Furthermore it also updates all dependencies of the packages listed as argument. conda update will update these even if the package in the argument is already the latest version.

A Roebel
  • 289
  • 2
  • 7
  • at least with conda 4.9.0, `conda update` will update only deps that aren't leaves (weren't installed explicitly). `conda update --update-deps` also updates leaves. – reddot Oct 26 '20 at 20:36
  • 2
    Perhaps also worth pointing out that `conda install` can take a version string (`conda install mypackage=1.1`) but `conda update` cannot. Specifying the version string installs that specific version, so `conda install` can also be used to _downgrade_ a package. – Teake Nutma Nov 04 '20 at 10:22
  • This at least identifies a difference between install and update, for an already installed package, but it does not explain the difference. – sancho.s ReinstateMonicaCellio Nov 13 '22 at 17:39