Jupyter Notebook and Anaconda – Jupyter Notebook is an interactive Python shell that runs in your browser. When installed through Anaconda, it is easy to quickly set up a Python development environment. Since it’s easy to set up and easy to run, it will be easy to learn Python.
What Is Jupyter Notebook and Anaconda?
Jupyter Notebook turns your browser into a Python development environment. The only thing you have to install is Anaconda. In essence, it allows you to enter a few lines of Python code, press CTRL+Enter, and execute the code. You enter the code in cells and then run the currently selected cell. There are also options to run all the cells in your notebook. This is useful if you are developing a larger program.
What Is Anaconda?
Anaconda is the easiest way to ensure that 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 the purposes of this guide, install the one for Python 2.7.
Anaconda is an open-source data science platform. It contains over 100 packages for use with Python, R, and Scala. You can download and install Anaconda quickly with minimal effort. Once installed, you can update the packages or Python version or create environments for different projects.
- Download and install Anaconda at https://www.anaconda.com/download.
- 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: http://localhost:8888. If you’re running Internet Explorer, close it. Use Firefox or Chrome for the best results. From there, browse to http://localhost:8888.
- 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 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 (https://www.anaconda.com/products/individual#Downloads) 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.