Rename conda Python environment

Change Python conda environment old to new by cloning the environment and deleting the original environment, as follows.

conda create --name new --clone old
conda remove --name old --all

Conda environment maintenance

Here are some quick tips for maintaining multiple conda environments.

Switch conda environments

Typically you might have different Python versions installed, or maybe large packages like PyCUDA that require older versions of Numpy, each in their own Python conda environment.

conda env list

shows the environments installed. Pick an environment by name (say, py27) by

. activate py27

Go back to your main conda environment by

. deactivate

Disk size

Each conda environment disk size can be checked by:

  1. list all environment paths
    conda env list
    

    Let’s say you have

    py27 ~/miniconda3/envs/py27

  2. print size of entire environment
    du -sh ~/miniconda3/envs/py27
    

    This could be several hundred MB or even a couple GB if you have a lot of modules installed, particularly if they include user data.

  3. If you want to delete a big conda environment (say py27) you’re not using anymore to save disk space, you can delete the environment by
    conda remote --name py27 --all
    

Notes

reference

Tags:

Categories:

Updated:

Leave a Comment