83

Over a period of time, I have loaded a number of packages into the Anaconda I have been using. Now I am not able to keep track of it. How do we get a list of all packages loaded in Anaconda (Windows 10)? What is the command?

Franck Dernoncourt
  • 62,576
  • 61
  • 286
  • 446
Regi Mathew
  • 1,715
  • 2
  • 15
  • 29
  • 1
    I don't know about Anaconda specifically, but for generic Python, third-party packages are usually installed in the site-packages folder. – John Gordon Sep 23 '17 at 03:06

6 Answers6

130

in terminal, type : conda list to obtain the packages installed using conda.

for the packages that pip recognizes, type : pip list

There may be some overlap of these lists as pip may recognize packages installed by conda (but maybe not the other way around, IDK).

There is a useful source here, including how to update or upgrade packages..

Reblochon Masque
  • 30,767
  • 8
  • 43
  • 68
  • Is there a way to list only top-level packages. Under top-level I mean those that aren't installed as a dependency of another package. – handras Mar 26 '19 at 11:16
  • As far as I know, there is no easy way to do that @handras – Reblochon Masque Apr 14 '19 at 05:09
  • 3
    @handras, now there is. From the [docs](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-an-environment-file-across-platforms): "If you want to make your environment file work across platforms, you can use the `conda env export --from-history` flag. This will only include packages that you’ve explicitly asked for, as opposed to including every package in your environment." – toliveira Sep 08 '20 at 19:18
  • Thanks for that @toliveira, very helpful! – Reblochon Masque Nov 07 '20 at 08:09
18

To list all of the packages in the active environment, use:

conda list

To list all of the packages in a deactivated environment, use:

conda list -n myenv
Rohaifa Khaldi
  • 181
  • 1
  • 2
  • `conda list` will not list packages in a deactivated environment... I wonder if there's a way to list packages in all environments... `conda list -n env1 -n env2` lists `env2` and ignores `env1`. Let me search that... – PatrickT May 25 '20 at 08:23
12

To check if a specific package is installed:

conda list html5lib

which outputs something like this if installed:

# packages in environment at C:\ProgramData\Anaconda3:
#
# Name                    Version                   Build  Channel
html5lib                  1.0.1                    py37_0

or something like this if not installed:

# packages in environment at C:\ProgramData\Anaconda3:
#
# Name                    Version                   Build  Channel

you don't need to type the exact package name. Partial matches are supported:

conda list html

This outputs all installed packages containing 'html':

# packages in environment at C:\ProgramData\Anaconda3:
#
# Name                    Version                   Build  Channel
html5lib                  1.0.1                    py37_0
sphinxcontrib-htmlhelp    1.0.2                      py_0
sphinxcontrib-serializinghtml 1.1.3                      py_0
A. Genedy
  • 320
  • 2
  • 9
2

For more conda list usage details:

usage: conda-script.py list [-h][-n ENVIRONMENT | -p PATH][--json] [-v] [-q]
[--show-channel-urls] [-c] [-f] [--explicit][--md5] [-e] [-r] [--no-pip][regex]
D. Schreier
  • 1,462
  • 1
  • 17
  • 29
Tejj
  • 91
  • 6
1

For script creation at Windows cmd or powershell prompt:

C:\ProgramData\Anaconda3\Scripts\activate.bat C:\ProgramData\Anaconda3
conda list
pip list
Das_Geek
  • 2,284
  • 7
  • 16
  • 24
Carmo Melo
  • 11
  • 1
1

To list all of the packages in the active environment in a format that resembles pip freeze:

conda env export

Example of output:

name: pytorch
channels:
  - pytorch
  - anaconda
  - conda-forge
  - defaults
dependencies:
  - python=3.8.5=h7579374_1
  - python_abi=3.8=1_cp38
  - pytorch=1.7.1=py3.8_cuda11.0.221_cudnn8.0.5_0
  - pytorch-lightning=1.1.4=pyhd8ed1ab_0
  - tensorboard=2.4.0=pyhd8ed1ab_0
  - pip:
    - bert-score==0.3.7
    - tokenizers==0.9.4
    - transformers==4.2.1
prefix: /home/franck/anaconda3/envs/pytorch

You can save the environment and re-create and/or reactivate it:

# Save the environment
conda env export > my_conda_env.yml

# Re-create the environment
conda env create --file my_conda_env.yml

# Reactivate the environment
conda activate pytorch 
Franck Dernoncourt
  • 62,576
  • 61
  • 286
  • 446
  • 1
    Hi, sorry to bother you here but it seems your Twitter account is hacked. – ayhan May 17 '21 at 18:09
  • @ayhan crap I'll look into it now – Franck Dernoncourt May 17 '21 at 18:11
  • @ayhan password reset and spam tweets removed, thanks very much! Bad coincidence and bad security practice from Twitter made me think the Twitter email about connection warning was me (why would Twitter say "connection from the US" in their connection warning without giving a more precise address or IP... dumb!). https://tweetdelete.net/ was very handy btw to clean spam tweets! – Franck Dernoncourt May 17 '21 at 18:15
  • 1
    Yeah that's not very informative for a suspicious login. Glad you got it back without any problem. – ayhan May 17 '21 at 19:11