Welcome to the world of data science! If you are just stepping into this exciting field, you have likely come across two essential tools in your journey: Jupyter Notebook and Anaconda.
In this beginner’s guide, we will explore what Jupyter Notebook and Anaconda are and how they can empower you to unleash the full potential of your data.
What Is Jupyter Notebook?
Jupyter Notebook is an open-source web application that allows you to create and share documents containing live code, equations, visualizations, and explanatory text. It provides a flexible and interactive environment for data analysis, experimentation, and collaboration.
When you launch Jupyter Notebook, you are greeted with an interface that enables you to create notebooks. These notebooks consist of cells that can contain either code or formatted text. This flexibility makes Jupyter Notebook an ideal tool for combining code execution, visualizations, and textual explanations.
Getting Started with Jupyter Notebook
To get started with Jupyter Notebook, you first need to install it. The installation process may vary depending on your operating system, but it is usually as simple as running a few commands. Once installed, you can launch Jupyter Notebook by running a command in your terminal or command prompt.
When Jupyter Notebook is up and running, you will see the familiar web-based interface in your browser. The interface consists of a file navigator, where you can organize your notebooks, and the main dashboard, where you can create new notebooks or open existing ones.
Understanding the Basics
Before diving into the power of Jupyter Notebook, it’s important to understand the basic building blocks of this tool. The fundamental unit in Jupyter Notebook is the cell. There are two types of cells: code cells and markdown cells.
Code cells are where you write and execute your code. You can write code in various programming languages, such as Python, R, or Julia, depending on your setup. Markdown cells, on the other hand, allow you to create formatted text, headings, and even mathematical equations using LaTeX syntax.
What Is Anaconda?
Now that we have covered the essentials of Jupyter Notebook, let’s explore the relationship between Jupyter Notebook and Anaconda. Anaconda is a popular open-source distribution of Python and R programming languages for data science and machine learning. It comes bundled with many pre-installed libraries and tools that are commonly used in data analysis.
By using Anaconda, you can effortlessly manage your Python or R environments and dependencies, ensuring that you have the necessary packages and versions without conflicting dependencies. This ability to create isolated environments can save you from potential headaches and allow you to work on different projects with different requirements seamlessly.
Anaconda is the easiest way to ensure you don’t spend all day installing Jupyter. Simply download the Anaconda package and run the installer. The Anaconda software package contains everything you need to create a Python development environment. Anaconda comes in two versions—one for Python 2.7 and one for Python 3.x. For this guide, install the one for Python 2.7.
Integrating Anaconda Navigator with Jupyter Notebook
Anaconda Navigator is a graphical user interface that simplifies managing environments and packages in Anaconda. It provides a convenient way to launch Jupyter Notebook, manage environments, and install additional packages without needing to use the command line.
With Anaconda Navigator, you can effortlessly navigate through your projects, start Jupyter Notebook with the click of a button, and access all the necessary tools for managing your data science workflow, making it an indispensable companion to Jupyter Notebook.
- Download and install Anaconda.
- Once you’ve installed Anaconda, you’re ready to create your first notebook. Run the Jupyter Notebook application that was installed as part of Anaconda.
- Your browser will open to the following address: “https://localhost:8888” (without quotes). If you’re running Internet Explorer, close it. Use Firefox or Chrome for the best results. From there, browse to “https://localhost:8888” (without quotes).
- Start a new notebook. On the right-hand side of the browser, click the drop-down button that says “New” and select Python or Python 2.
- This will open a new iPython notebook in another browser tab. You can have many notebooks open in many tabs.
- Jupyter Notebook contains cells. You can type Python code in each cell. To get started (for Python 2.7), type print “Hello, World!” in the first cell and hit CTRL+Enter. If you’re using Python 3.5, then the command is print(“Hello, World!”).
How to create an environment in Conda and Jupyter?
Let’s imagine you want to use Jupyter Notebook to install both Tensorflow 2.0 and Tensorflow 1.15.
First, decide whether you want to utilise Tensorflow on the GPU or the CPU for this example. Add “-gpu” to TensorFlow to use the GPU version; otherwise, leave it alone.
We may use the following command to build a new conda environment.
When you run the following command, you should see three environments if everything went well:
conda create --name tf-2.0 conda create -n tf-2.0 tensorflow-gpu pip ipykernel conda create -n tf-1.15 tensorflow-gpu==1.15 pip ipykernel conda env list
Anaconda is a useful package that already includes a number of Python packages and provides for a quick entry into the Python world. It also allows you to create Python environments that contain multiple versions of your Python packages. For example, if a programme only runs on Python 2.7 or older versions of Matplotlib, you may establish a separate workspace for it and switch to Python 3 with a single click.
Additionally, moving between Tensorflow 2.0 and Tensorflow 1.15 is simple, allowing you to simply swap between versions (which can be quite a headache otherwise).
Miniconda is a stripped-down version of Anaconda that might be useful if you’re working on a server with limited storage space.
To install Anaconda or Miniconda, go to their website or copy the following instructions into your terminal if you’re using Linux.
When you run Jupyter Notebook in the basic environment, you should see a tab with “Extensions” and “conda”/”environments.” Go to Extensions and enable any extensions you want, then use the “new” button to create a new notebook if you’re ready. You should be able to select your basic, tf-2.0, or tf-1.15 environment here.
You must run jupyter notebook in the basic environment at all times. To exit your current environment and return to the basic one, runconda deactivate.
If you need to install more packages, activate an environment with conda activate [NAME], perform your commands with conda install Xorpip install X, and then deactivate it with conda deactivate.
Jupyter Notebook and Anaconda are powerful tools that can unleash your data superpowers, enabling you to analyze, visualize, and share data effectively. By following this beginner’s guide, you should now have a solid understanding of Jupyter Notebook and how it integrates with Anaconda. So, what are you waiting for? Dive in, explore, and unlock the limitless possibilities of your data!