Conda
Installation
5 steps:
1 | # create a directory to install minicaonda in |
Environment & Library
Create a new environment:
1 | conda create -n [newevname] python=[YourVersion] |
Switch to another environment:
1 | conda activate [evname] |
conda deactivate
will make you exit the current environment and turn back tobase
environment.
Rename an environment:
1 | conda create -n [newevname] --clone [oldenvname] |
If there are some packages or programs related to the environment name (e.g. jupyter notebook), avoid renaming or copying. Actually, the commands above are
clone
andremove
commands.
Install a new library:
1 | conda install [libname] |
pip
can also be used to install new libraries. Useuninstall
to uninstall the library you don't need.
Information
List all installed libraries in the current environment:
1 | conda list |
List all the virtual environments you have created:
1 | conda env list |
Sharing
To share your environment with others, you should first export your configuration to a yml
file:
1 | conda env export > [filename].yml |
The
yml
file will be created in your current folder.
Then, the yml
file can be used to create an environment that is the same as yours:
1 | conda env create -f [filename].yml |
The first line of the
yml
file is the name of the created environment. You should make sure that theyml
file is in your current folder.
Configuration
Create .condarc
:
1 | conda config --add channels r |
Tsinghua mirror and env path:
1 | channels: |