Conda notes

From raju

Note:- This page will be migrated to Once the migration is done, it will be deleted.

replicate environment

Method 1

Check the environments installed

    conda info --envs

Export the environment

    conda env export --name FOO | grep -v "^prefix: " > environment.yml

Note: By default, the output of "conda env export" contains a line

    prefix: /path/to/the/environment

This line is not necessary in order to recreate the environment. Grepping it out so that the replicating user will not know what the original environment's path is.

Another way

  • On Windows
    activate myenv
    conda env export | grep -v "^prefix: " > environment.yml
  • On Linux
    source activate myenv
    conda env export | grep -v "^prefix: " > environment.yml
    source deactivate

To recreate it

    conda env create -f environment.yml
    activate myenv


Method 2

Get the list of packages

    $ conda list --export --name old_environment > req.txt


    $ conda list -e -n old_environment > req.txt

Create a new environment using

    $ conda create -n new_environment --file req.txt



List all the environments

    conda info --envs

clone an environment

tags | copy environment

    conda create --name new_environment --clone old_environment


rename an environment

    conda create --name $newName --clone $oldName
    conda remove --name $oldName --all


create an environment from a file

    conda env create -f env.yml

Create an environment

Always specify the python version you want while creating the environment. For example

    conda create --name foo python=2.7

If python version is not specified, there will not be a python.exe under the corresponding environment directory /c/ProgramData/Continuum/Anaconda/envs/foo . The python.exe is needed to link this environment in pycharm when choosing the python interpreter path.

Sample commands I used in the past:

    conda create -n market_data_processor python=3.6 pandas pep8 pandas-datareader

Sample commands I came across:

    conda create -n py37 python=3.7.0 pandas=0.23.4 line_profiler=2.1.2

Create an environment for python 3.6

    conda create -n py36 python=3.6 anaconda

Switch to the new environment

    activate py36

create and remove environment in nonstandard location

To create environment foo

    conda env create -p foo -f env.yml

This will create a foo directory under the current working directory and place all environment specific files underneath it.

To remove

    conda env remove -p foo

list current environment

Use $CONDA_DEFAULT_ENV to get the current environment name. For example

    $ source activate py36

This is useful to activate a conda environment if it is not the current environment. See for example

install a specific version of a package in an environment

    conda install -n <env> <package>=<version>

For example

    conda install -n py27 pandas=0.19.2

list available package versions

path to python

The python used by an activated conda environment is ${CONDA_PREFIX}/bin/python

activate and deactivate environments

To activate environment foo

    conda activate foo

To deactivate

    conda deactivate

activate a conda environement if it is not already activated

    # desired environment is set to py36. Change it as needed.
    if [[ $current_env != $desired_env ]];
        echo "setting environment to $desired_env"
        source activate $desired_env

In action |

Specifying version numbers

shows how to | specify minimum version in the environment file

Constraint type Specification Result
Fuzzy numpy=1.11 1.11.0, 1.11.1, 1.11.2, 1.11.18 etc.
Exact numpy==1.11 1.11.0
Greater than or equal to "numpy>=1.11" 1.11.0 or higher
1.11.1, 1.11.3
AND "numpy>=1.8,<2" 1.8, 1.9, not 2.0

Ref:- -> pg-2 -> "Specifying version numbers" section

file locations

  • pep8 - /c/ProgramData/Anaconda3/Scripts/pep8.exe
  • python interpreter - /c/ProgramData/Anaconda3/python

getting help

    conda create --help

This command helped me to find out that '-p' is a shortcut for --prefix in the command 'conda env create -p PATH'.

useful links

breaking changes

  • Starting from conda 4.4.0, the 'root' environment is referred to as the 'base' environment.

Ref:- -> "Deprecations/Breaking Changes" section -> first point.

Anaconda channel vs defaults channel

The anaconda channel on is a mirror and is not the place to install packages from. The default channels/packages are hosted from So if a package such as prompt_toolkit is uploaded to the defaults channel, it will first show up in and then eventually in .




uninstall anaconda

useful links

installation related



I was getting

    NoPackagesFoundError: Package missing in current linux-64 channels: 
      - python 3.8*

on a system running:

     % conda --version
    conda 4.3.22

I was able to fix the issue by removing the existing anaconda installation and installing the latest miniconda ( For reference, I now have

     % conda --version
    conda 4.8.

[Errno 13] Permission denied

If you get

    [Errno 13] Permission denied: 'C:\\Path\\to\\libEGL.dll'

Close the git bash and relaunch it.

TypeError: '<' not supported between instances of 'NoneType' and 'str'

"conda env export --name foo" was giving the following error

    TypeError: '<' not supported between instances of 'NoneType' and 'str'

I was able to fix it by upgrading conda from 4.6.14 to 4.9.1