Basic Conda Guide
Posted on Jul 16, 2018 in tutorial • 11 min read
Basic Conda Guide¶
What is Conda¶
It is short for Anaconda, the most popular Python data science platform. It is a Python and R distribution. It aims to provide almost everything you need for data science as it makes it easy to install Python plus a number of it's most often used 3rd party libraries in a flexible way. Personally, I prefer it over Vanilla and other virtual environments.
How to Install Conda¶
Official guide to installation for different OS
- Download graphical installer according to your OS and choose your Python version.
macOS
Windows
For Linux, only command-line install is supported. Check the official guide above. - Open the installer and follow the instructions
Verify the Installation¶
Open Anaconda Prompt (or Terminal on Linux or macOS):
- Windows: Open the Anaconda Prompt (Click Start, select Anaconda Prompt)
- macOS: Open Launchpad, then open Terminal.
- Linux–CentOS: Open Applications - System Tools - Terminal.
- Linux–Ubuntu: Open the Dash by clicking the upper left Ubuntu icon, then type “terminal”.
Enter
conda list
. If Anaconda is installed and working, this will display a list of installed packages and their versions.
Getting Started¶
- Update conda to the current version
conda update conda
- Create a new environment, assign a name to it, and specify its Python version
conda create --name <envname> python=<version:2.7/3.5>
- Activate this environment. If successfull,
(envname)
should show up in front of the prompt in the terminal
conda activate <envname>
- Use regular installation commands to install packages after environment succesfully activated
pip install -r requirements.txt
- Check if a package is available from the Anaconda repo
conda search <packagename>
- Show a list of all the packages installed in this environment with an asterisk after the name of the active environment
conda list
- Export a list of all installed packages to txt
conda list -e > requirements.txt
- Show a list of all your conda environments
conda info --envs
NOTE¶
- When using regular
pip install
for large numbers of packages, the entire installation process could freeze or fail due to a single error in the numerous packages. In such case, run the following command instead to retain successful installations.
while read requirement; do conda install --yes $requirement; done < requirements.txt
Official Cheat Sheet¶