Created
February 3, 2017 16:08
-
-
Save nitya/ea235472c9aa2f205fd49f156e0914cd to your computer and use it in GitHub Desktop.
Quick Anaconda Review (for Udacity Deep Learning ND Foundations Program)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Anaconda | |
* Distribution of libraries and software specifically built for data science. | |
* Conda = package and environment manager | |
* Best practices = create a new enviornment for each chapter | |
* Then use "conda install" to install dependencies (modules) | |
* Use "conda list" to view all installed package in the environment | |
* You can also export the environment (package listing) to a file. Share that with others to enable them to replicate your environment when running code. | |
### Installing Anaconda | |
1. Available for Windows/MacOS/Linux. Installers here: [https://www.continuum.io/downloads](https://www.continuum.io/downloads) | |
2. Complements existing Python dist on computer. _Default Python used by programs will be that installed by Anaconda_ | |
3. Udacity recommends: Python 3.5, 64-bit installer | |
4. I have: Anaconda 4.3.9 for OSX (Python 2.7, 64-bit) | |
- I used ```conda update anaconda``` to update it from my previous 4.1.x version but it had conflicts with updating python versions | |
- Instead I had to delete/move the "anaconda" directory from my home and then reinstall a fresh version from the downloaded package | |
5. Now have: Anaconda 4.3.x on Python 3.6 _however this removes previously created environments so I need to redo those_ | |
### Managing Packages | |
Once you have Anaconda installed, managing packages is fairly straightforward. | |
1. Install package: e.g., ```conda install numpy``` | |
2. Install multiple packages: e.g., ```conda install numpy scipy pandas``` | |
3. Install specific version of package e.g., ```conda install numpy=1.10``` | |
4. Install dependencies e.g., ```conda install scipy``` also installs _numpy_ which _scipy_ depends on | |
5. Update package: ```conda update tensorflow``` (for one) or ```conda update --all``` to update all packages in that environment | |
6. List installed packages in environment: ```conda list``` | |
7. Remove package: ```conda remove tensorflow``` | |
8. Search for package ```conda search beautifulsoup``` | |
### Managing Environments | |
1. Create a new "named" environment: ```conda create -n my_new_env numpy tensorflow``` (where -n provides arg for name) | |
2. Specify default python install for environment during creation: ```conda create -n my_new_env python=3 numpy tensorflow``` (use version can be general e.g., "2" or "3" - or specific e.g., "3.3") | |
3. Activate environment: ```source activate my_new_env``` (environment name will appear in terminal prompt as prefix) | |
4. Deactivate environment: ```source deactivate my_new_env``` | |
5. Running ```conda install``` (or other package management commands) within an activated environment ensures changes are localized to that environment. | |
### Saving and Loading Environments | |
1. Save environment: as metadata in _YAML_ format => ```conda env export > environment.yaml``` | |
2. Load environment: recreate from _YAML_ => ```conda env create -f environment.yaml``` | |
3. Note to self: save env to _yaml_ for any project by default. If you need to upgrade or move Anaconda and lost your previous created environments, this lets you restore them from files. | |
4. Listing enviroments: ```conda env list``` | |
5. Remove outdated environments ```conda env remove -n env_name``` | |
### Best Practices | |
1. Using environments: _recommends created pre-defined py2 and py3 named environments corresponding to Python2 and Python3 versions. Simplies the ability to do general purpose coding for each case_ | |
2. Sharing environments: _recommends always creating saved env file for projects to allow others to restore/replicate your work._ (Note to self: let's use convention of adding _conda_env.yaml_ as default named file for project ) | |
3. Conda doc: [website](http://conda.pydata.org/docs/using/index.html) | |
4. Conda myths: [JVP article](https://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment