Command Tips for Miniconda, which is the execution environment of Python. The documentation isn't very complete ... or rather, it feels like it's hard to reach, so I'll summarize it.
Command Flow
#Create a virtual environment(something like virtualenv)
conda create -n my_env numpy scipy
#Display a list of virtual environments
conda info -e
#Enable virtual environment
activate my_env # Windows
source activate my_env # Max/Linux
#Additional installation in virtual environment(When specifying the version conda install scipy=0.12.0 etc.)
conda install scikit-learn
#Install with pip for things that can't be obtained with conda(Support by putting pip in the virtual environment)
conda install pip
pip install Flask
#Export the library installed by conda
conda list --export > conda_requirements.txt
#Update installed packages(conda itself is conda update conda)
conda update numpy
#Disable virtual environment
deactivate # Windows
source deactivate # Max/Linux
#Create a virtual environment from a file
conda create -n my_new_env --file conda_requirements.txt
#It seems that conda env export is good to use these days
conda env export > environment.yml
conda env create -f environment.yml
If you are using pyenv, the shell may crash with source activate. This seems to be a phenomenon caused by pyenv activate and conda activate batting, see here for the solution. Specify the activate of conda with the full path.
References
Using the Anaconda Python Distribution Advanced Features of Conda Part 1 Conda FAQ
Recommended Posts