---
title: Anaconda Jump Start
tags: Python Cheatbook
---
# Anaconda Jump Start
In this article I will walk through the following commands
```console
conda env list
conda create --name myfirstenv python=3.8
conda activate myfirstenv
conda search numpy
conda install numpy
conda list
conda install -channel conda-forge boltons
conda remove numpy
conda remove --name myfirstenv boltons
conda list --explicit > myfirstenv.txt
conda env create --file myfirstenv.txt
conda list --revisions
conda install --revision 2
conda install --revision 1
conda deactivate
```
Anaconda is an enviornment manager for Python. It allows you to keep a set of packages in different enviornments for different purpose.
For example, if you make games and do machine learning stuff with python then you would want to keep those two enviornments separately so that the libraries are compatible throughout the development as your project ages.
Download here: https://www.anaconda.com/
It comes with python, so installing this is enough.
# Dealing with Enviornments
Once you have it installed, you can run Anaconda via terminal using the commands below. It does come with a GUI manager but its much better to work with these commands first because GUIs can be buggy or slow.
First, list down a set of enviornments.
```console
conda env list
```
You will notice there is only a base enviornment, this is the default place where everything would get installed if your enviornment is not selected.
When starting a new project, create a new enviornment.
```console
conda create --name myfirstenv python=3.8
```
This will create a new enviornment called `myfirstenv` with Python 3.8. Run the `env list` command again to see your new enviornment.
You can now activate it and make use of it in your projects.
```console
conda activate myfirstenv
```
# How do I use my enviornments in my IDE?
## Visual Studio Code
You can switch your interpreter after opening a Python file. There is a shortcut on bottom left.

## PyCharm
You can check the python interpreter settings and chose your enviornments from there. It will give you an option to either use existing one, or make a new one. There is a shortcut in the bottom right.

# Downloading packages
Now you know how to use your enviornments it is time to know how to download packages.
Example, search for a package `numpy`.
```console
conda search numpy
```
This will return a list of all the avilable packages called `numpy` from its **channels** (place where it looks for packages). let's install it.
```console
conda install numpy
```
depending on which enviornment is active, it will go and install the package into that enviornment, currently for me its `myfirstenv`.
**Note: If you cannot find your package then update the list of channels it can access.**
Install a package `boltons` from a specific channel `conda-forge`.
```console
conda install -channel conda-forge boltons
```
If you aren't sure which channel to look into, simply google your package name with a `conda` prefix. You can also add the channel permentantly so you don't have to specify channel name everytime, [refer to channel documentation for more info](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html).
You can also install a package using `pip` the default Python package manager.
To remove package `boltons`.
```console
conda remove --name myfirstenv boltons
```
`--name myfirstenv` is not required if your enviornment is already active, this is just an example to be specific.
# I am ready, I want to share the enviornment with my friends (or professor).
Export it to a text file called `myfirstenv.txt`.
```console
conda list --explicit > myfirstenv.txt
```
Ask your friend to import from text file `myfirstenv.txt` using the following command.
```console
conda env create --file myfirstenv.txt
```
Great, oh and if you screw up at a point and want to revert your enviornment then you can use the following commands.
```console
conda list --revisions
```
Rollback to $n^{th}$ ($2^{nd}$ in this example) revision
```console
conda install --revision 2
```
check all your packages.
```console
conda list
```
==One of the import use case of this is when you install packages in the **base** enviornment and want to reset it to default state. Simply run this on the base enviornment.==
```console
conda install --revision 1
```
*Note: Go to revision 1, as going to revision 0 might remove the base version. The removal will take some time and it might seem its not working but don't worry, check your RAM usage as it increases slowly. It will evnetually give a prompt (or press enter if it seems stuck after few mins).*
# Time to get rid of an enviornment so that I can install some games.
Unfortunately having multiple enviornments can take up some storage on your machine so it would be a good idea to delete it. Before you delete just make sure you export the enviornment incase you need it again.
First deactivate the enviornment if its active.
```console
conda deactivate
```
Then remove it.
```console
conda env remove --name myfirstenv
```
✋
# Resources
1. Official Anaconda Cheatsheet: https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf (bookmark it 🤓)