Ben2209
Ben2209

Reputation: 1121

list anaconda packages for which I specified version number

Is there a way to list the packages for which I specified the version number. For example, if I specified scipy version but not numpy version by installing them like this: conda install scipy=0.15.0 numpy, I would like to be able to know that I specified version 0.15.0 for scipy. Furthermore, how can I unspecify a package version if I do not want to specifically use that version but I would rather like to get the latest possible version?

Upvotes: 2

Views: 490

Answers (2)

merv
merv

Reputation: 77090

Conda History Log

Conda tracks each env's entire history in a log file at conda-meta/history. There is an existing answer about searching this file, which would work to retrieve such information.

Export Explicit Specs

However, Conda itself tracks what are called "explicit specs", which refer to specifications that the user has explicitly requested to be installed. A newish (v4.7.12) feature in the conda env export command is to output only explicit specs, and this would be a simple way to get down to the OP request:

conda env export --from-history

Be aware, however, that unfortunately some commands (e.g., conda install --update-deps) can trigger auto-adding explicit specs, which could nullify the usefulness. In that case, one likely has to resort back to grep'ing though the history log.

Redefining Explicit Specs

As for redefining specs, there is again a newish (v4.7.6) feature for the conda install command that does exactly that, namely --update-specs. For example, suppose we have an env, foo, with scipy=1.1. Using --update-specs would trigger upgrading from the previous constraint:

conda create -n foo scipy=1.1
conda install -n foo --update-specs scipy

Upvotes: 3

Karthick Mohanraj
Karthick Mohanraj

Reputation: 1658

There is no any programmatic way to extract the information you are looking for. The only way I could think of is by extracting the history of the commands you typed while installing your packages through your terminal (in case of mac or linux machines) or command prompt (in case of windows machine).

  1. For checking the history of typed commands in MAC or LINUX:

    Type history in your terminal window

  2. For checking the history of typed commands in Windows:

    Type doskey /history or press F7 key inside your command prompt

After extracting this history of commands you typed, you can create a piece of code to check for commands in which you have specified version numbers.

How can I unspecify a package version if I do not want to specifically use that version but I would rather like to get the latest possible version? You can just do pip install [package_name] --upgrade in case of pip or conda update [package_name] in case of conda to upgrade a package to its latest version

Upvotes: 1

Related Questions