First Step with Python – How to Install Anaconda & Set Up New Environment(s)




In this article, we’ll first give you a basic introduction of Anaconda, then a simple instruction about how to install Anaconda and set up new environment(s) before using it.



Topic 01: What is Anaconda?


Anaconda is a free and open-source distribution of Python and R developed by Anaconda Inc. After installing it, one can quickly set up Python environment(s) on his or her computer, install / uninstall / manage packages (e.g., scikit-learn, PyTorch, TensorFlow, Keras, etc.), accessing related applications (e.g., Jupyter Notebook, PyCharm, Spyder, etc.) and so on (see Figure 1).


Figure 1. "Home" of Anaconda Navigator. After installing Anaconda Distribution, one can easily access Python- and R-related applications such as Jupyter Notebook, PyCharm and Spyder through the home page of Anaconda Navigator.

After installing Anaconda, one can also use the key word conda to install, uninstall, update or perform other actions on Python packages. To see a list of complete functions of the command, just input “conda” in your terminal (for Mac) or command prompt (for Windows) and press enter.


[Appendix] Jupyter Notebook, PyCharm & Spyder

  • Jupyter Notebook: An open-source web application that allows one to share documents containing live code, equations, visualizations and narrative text. One can also run code with Jupyter Notebook, see the instant responses, and store those responses.


  • PyCharm: PyCharm is a professional Python IDE (Integrated Development Environment), in which people can organize and edit their Python programs in the context of projects.


  • Spyder: A simpler Python IDE that allows one to see instant results of Python code with multiple IPython consoles.



Topic 02: Install Anaconda to your computer


To install Anaconda to your computer, simply go to Anaconda "Products" page and download the installer appropriate for your operating system (Mac, Windows or Linux). After that, double click the installer you just downloaded and follow the instruction shown on the screen. If you are not familiar with terminal / command prompt, we recommend you to download the graphical installer; otherwise, you can select command-line installer if you like.


After the installation, go to the home of Anaconda Navigator, and you will see several blocks with different applications in it. At the bottom of these blocks you can see a button saying “launch” or “install”. If the button shows “launch”, it means that the application has already been installed, and you can open the application by simply clicking the very button. If it shows “install”, it means that the application hasn’t been installed yet, and you can install it by clicking “install”. We recommend you to finish the installation of Jupyter Notebook, PyCharm and Spyder.


For Mac users, if you have installed Anaconda on macOS 10.14 Mojave (or earlier version) and have recently updated your macOS to 10.15 Catalina (or later), it’s likely that you can no longer open your Anaconda since its default install location in the root folder is not allowed. To resolve such issue, please refer to the official article released by Anaconda Inc (we recommend you to reinstall Anaconda instead of trying to fix the existing installation).



Topic 03: Set up new environment


One of the biggest problems of Python is that different packages are created by different groups, and they will sometimes conflict with or even corrode each other. If that happen, you may not be able to update your packages / Anaconda Navigator or use your environment(s) normally. Thus, before you start using Anaconda, it’s very important to create a new environment and perform all kinds of modifications (e.g., installing new packages) on it rather than the default base (root) environment (i.e., you should leave the base (root) environment unchanged).


To create a new environment with Anaconda, go to the “environments” label and click Create button at lower left (see Figure 2). By doing so, you can create a new environment with fundamental packages installed.


Figure 2. Create a new environment before you use Anaconda. Be sure to keep the default “base (root)” environment unchanged so that you can use and update Anaconda smoothly in the future.

If you’d like to clone an existing environment so that the new environment has all the packages from the cloned environment, select the environment you want to replicate and click the Clone button instead (Figure 3).


Figure 3. Clone an existing environment. The new environment will contain all packages that have already existed in the cloned environment.

Note that when naming your environment, DO NOT use the name composing of two or more words (e.g., do not use a name such as “test environment”; instead, use “test_environment” if this is what you are going for). Otherwise, you may not be able to launch the environment correctly (e.g., Jupyter Notebook and terminal won’t open while under the environment).


By keeping the base (root) unchanged, you can always update your Anaconda Navigator while under this default environment. And if any environment accidentally breaks in the future (e.g., you can’t open Jupyter Notebook under a certain environment), you can just remove it with Anaconda by clicking the Remove button and create a new one.


To install new packages to an environment, follow the steps below. First, make Anaconda Navigator shows all packages. Then, search for the package you’d like to install with its name; check the checkbox in front of the very package, and click the Apply button at lower right (Figure 4).



Figure 4. To install new packages, following the steps above.

After the steps said, you can see a small window pops up indicating that Anaconda is solving package specifications for you. When that’s done, you can see which packages will be installed or modified. Just click Apply on the small window and wait for the installation process to be completed (Figure 5).


Figure 5. Click the “Apply” button on the small window to initiate the installation process.

Finally, to use your newly created environment, click the environment so that a green triangle-shaped arrow appears on the right side of the name of your environment (switching environments can take a few seconds). Then, click on the green arrow, and you will see all the actions you can choose from, including Open terminal, Open with Python (open CPython, the default and one of the most widely used implementation of Python, on a terminal / command prompt window), Open with IPython and Open with Jupyter Notebook (Figure 6).


Figure 6. The actions you can perform with your newly created environment.


Footnote: Neurozo Innovation provides viewpoints, knowledge and strategies to help you succeed in your quest. If you have any question for us, please feel free to leave a comment below or e-mail us. For more articles like this, please follow our Twitter, Facebook page, or LinkedIn. Thank you very much for your time, and we wish you a wonderful day!