How to install jupiter notebook
How to install jupiter notebook
How To Install Jupyter Notebook Using PIP
Jupyter notebooks are pretty much necessary to get going with data science using python or R.
Here is the way you can install it using PIP
Step 1: Create a virtual environment.
Run following command in the command prompt.
This will install a package called virtualenv, which can be used to create a virtual environment.
To make sure that virtualenv was installed successfully, run following command.
Good! Now let’s create a virtual environment.
It is as simple as that!!
I highly prefer using git bash(If you are using windows).
Now that you have created the virtual environment, you can activate it by…..
If there is the name of virtual environment you just created in the brackets, then the environment is activated and you are good to go!
Step2: Installing Jupyter lab and jupyter notebook
First, we need to make sure that you have IPyKernel installed.
Use the command…
Then its time to install Jupyterlab.
Woohoo!! You can now open up Jupyter lab and run python notebooks.
Next step is to finally install Jupyter notebook.
Fire up jupyter notebook!
Notebook generally opens on Pout 8888, so make sure that other software won’t clash with it.
If you are facing any problems, please mention them in the comment…..
How to install Jupyter Notebook on Windows?
Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text. Uses include data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
Jupyter has support for over 40 different programming languages and Python is one of them. Python is a requirement (Python 3.3 or greater, or Python 2.7) for installing the Jupyter Notebook itself.
Jupyter Notebook can be installed by using either of the two ways described below:
Using PIP:
Install Jupyter using the PIP package manager used to install and manage software packages/libraries written in Python. To install pip, go through How to install PIP on Windows? and follow the instructions provided.
Installing Jupyter Notebook using Anaconda:
Anaconda is an open-source software that contains Jupyter, spyder, etc that are used for large data processing, data analytics, heavy scientific computing. Anaconda works for R and python programming language. Spyder(sub-application of Anaconda) is used for python. Opencv for python will work in spyder. Package versions are managed by the package management system called conda.
To install Jupyter using Anaconda, just go through the following instructions:
Launching Jupyter:
Installing Jupyter Notebook using pip:
PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI).
pip uses PyPI as the default source for packages and their dependencies.
To install Jupyter using pip, we need to first check if pip is updated in our system. Use the following command to update pip:
After updating the pip version, follow the instructions provided below to install Jupyter:
Launching Jupyter:
Use the following command to launch Jupyter using command-line:
How To Set Up Jupyter Notebook with Python 3 on Ubuntu 18.04
Introduction
Jupyter Notebook is an open-source web application that lets you create and share interactive code, visualizations, and more. This tool can be used with several programming languages, including Python, Julia, R, Haskell, and Ruby. It is often used for working with data, statistical modeling, and machine learning.
This tutorial will walk you through setting up Jupyter Notebook to run from an Ubuntu 18.04 server, as well as teach you how to connect to and use the Notebook. Jupyter Notebooks (or simply Notebooks) are documents produced by the Jupyter Notebook app which contain both computer code and rich text elements (paragraph, equations, figures, links, etc.) which aid in presenting and sharing reproducible research. In the final step of this guide, you will run Python 3 code using a Jupyter Notebook running on a remote server.
Prerequisites
In order to complete this guide, you will need an Ubuntu 18.04 server instance with a firewall and a non-root user with sudo privileges configured. You can set this up by running through our initial server setup tutorial.
Step 1 — Setting Up Python
To begin the process, install the dependencies for your Python programming environment from the Ubuntu repositories. Ubuntu 18.04 comes preinstalled with Python 3.6.9. You will use the Python package manager pip to install additional components later.
First, update the local apt package index:
Next, install pip and the Python header files, which are used by some of Jupyter’s dependencies:
You can now move on to setting up a Python virtual environment.
Step 2 — Creating a Python Virtual Environment for Jupyter
With some dependencies installed, you can create a Python virtual environment to manage your projects. Jupyter will be installed into this virtual environment.
You will need access to the virtualenv command which can be installed with pip.
First, upgrade pip by typing:
Then install virtualenv with this command:
Create your directory by typing the following command:
Move into the my_project_dir with this command:
Within the project directory, create a Python virtual environment. This tutorial will refer to the environment as my_project_env but, again, you can call it something that is relevant to your project.
This creates a directory called my_project_env within your my_project_dir directory. Inside, it will install a local version of Python and a local version of pip. You can use this to install and configure an isolated Python environment for Jupyter.
Before installing Jupyter, activate the virtual environment. You can do that by typing:
Your prompt should change to indicate that you are now operating within a Python virtual environment similar to this:
You’re now ready to install Jupyter into this virtual environment.
Step 3 — Installing Jupyter
With your virtual environment active, install Jupyter with the local instance of pip.
At this point, you’ve successfully installed all the software needed to run Jupyter. You can now start the Notebook server.
Step 4 — Running Jupyter Notebook
You now have everything you need to run Jupyter Notebook. To run it, execute the following command:
If you are running Jupyter Notebook on a local computer (not on a server), you can navigate to the displayed URL to connect to Jupyter Notebook. If you are running Jupyter Notebook on a server, you will need to connect to the server using SSH tunneling as outlined in the next section.
At this point, you can keep the SSH connection open and keep Jupyter Notebook running or you can exit the app and re-run it once you set up SSH tunneling.
You can now set up an SSH tunnel to access the Notebook.
Step 5 — Connecting to the Server Using SSH Tunneling
The next two subsections describe how to create an SSH tunnel from a Mac, Linux, and Windows operating system. Please refer to the subsection for your local computer.
SSH Tunneling with a Mac or Linux
If you are using a Mac or Linux, the steps for creating an SSH tunnel are similar to using SSH to log in to your remote server, except that there are additional parameters in the ssh command.
SSH tunneling can be done by running the following SSH command in a new local terminal window:
Optionally change port 8888 to one of your choosing to avoid using a port already in use by another process.
server_username is your username (e.g. sammy ) on the server which you created and your_server_ip is the IP address of your server.
SSH Tunneling with Windows and Putty
If you are using Windows, you can create an SSH tunnel using Putty.
First, enter the server URL or IP address in the Host Name (or IP address) field as shown:
Next, click SSH on the bottom of the left pane to expand the menu, and then click Tunnels. Enter the local port number you want to use to access Jupyter on your local machine. Choose 8000 or greater to avoid ports used by other services, and set the destination as localhost: 8888 where :8888 is the number of the port that Jupyter Notebook is running on.
Click the Add button, and the ports should appear in the Forwarded ports list:
Whether you’re connecting within a Mac/Linux OS or Windows, you should now be connected to your server via SSH tunneling. You’re now ready to use Jupyter Notebook in your web browser.
Step 6 — Using Jupyter Notebook
If you don’t currently have Jupyter Notebook running, start it with the jupyter notebook command:
You should now be connected to it using a web browser. Jupyter Notebook is a very powerful tool with many features. This section will outline a few of the basic features to get you started using the Notebook. Jupyter Notebook will show all of the files and folders in the directory it is run from, so when you’re working on a project make sure to start it from the project directory.
To create a new Notebook file, select New > Python 3 from the top right drop-down menu:
You can use the markdown cells to make notes and document your code. To implement that equation and print the result, click on the top cell, then press ALT + ENTER to add a cell below it. Enter the following code in the new cell.
You now have the ability to import modules and use the Notebook as you would with any other Python development environment.
Conclusion
You should now be able to write reproducible Python code and notes in Markdown using Jupyter Notebook. To get a quick tour of Jupyter Notebook from within the interface, select Help > User Interface Tour from the top navigation menu to learn more.
From here, you can begin a data analysis and visualization project by reading Data Analysis and Visualization with pandas and Jupyter Notebook in Python 3.
If you’re interested in digging in more, you can read our series on Time Series Visualization and Forecasting.
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
Install Jupyter Notebook
By Priya Pedamkar
What is Jupyter Notebook?
This article will have a closer look at Install Jupyter Notebook but first, study the Jupyter Notebook. Project Jupyter is created to develop open-source software and provide interactive computing service across different types of programming languages. Jupyter mainly supports 3 core programming languages: Julia, Python, and R. Jupyter Notebook is a web-based interactive environment that provides computational power. It provides Jupyter Web Application, Jupyter Python Web Server and Jupyter document format.
Web development, programming languages, Software testing & others
Installation of Jupyter Notebook
1. Directly Using Python
Code:
python –m pip install –upgrade pip
Code:
‘pip install jupyter.’
Code:
2. Install Jupyter notebook is using Anaconda
3. Now onstall Jupyter notebook
Code:
‘conda install Jupyter’
4. Run the Jupyter notebook
Code:
Now we know that installation is done. Know the time to know how to stop Jupyter notebook.
5. Stop Jupyter notebook
There are two ways to stop running the Jupyter notebook.
Features of Jupyter Notebook
There is a ‘New’ option on the right side.
It will give 4 option to create different types of files:
1. Python 3
File it will open a Notebook that contains:
2. Text
The file will give a simple blank page for creating the text files.
3. Folder
Option to create a folder in the directory of the Jupyter Notebook. Rename and delete the folders on your requirements.
4. Terminal
Terminal exactly works as it works on your local machines like Mac, Linux or cmd in windows. It is not limited to python language, but we can also write R, Julia, and JavaScript programs. It provides a feature of an interactive dashboard in Jupyter notebook. It means it also provides an option to add widget functionality. If we have taken a text widget, then text can be stored or can be used in the next cell.
Conclusion
Jupyter notebook is a web application widely used by the developer community, which helps the developer write and share code documents. A Developer can easily access their code and data. Use it to run, look at the instant output of the code cell and visualize the data. Notebooks are a very flexible, interactive, useful, and powerful tool in the hands of data scientists.
Recommended Articles
This is a guide to the Install Jupyter Notebook. Here we discuss the basic concept of installing a jupyter notebook in two forms and its features, respectively. You can also go through our other related articles to learn more-
Python Training Program (36 Courses, 13+ Projects)
Jupyter Notebook: An Introduction
Table of Contents
Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with the written tutorial to deepen your understanding: Using Jupyter Notebooks
The Jupyter Notebook is an open source web application that you can use to create and share documents that contain live code, equations, visualizations, and text. Jupyter Notebook is maintained by the people at Project Jupyter.
Jupyter Notebooks are a spin-off project from the IPython project, which used to have an IPython Notebook project itself. The name, Jupyter, comes from the core supported programming languages that it supports: Julia, Python, and R. Jupyter ships with the IPython kernel, which allows you to write your programs in Python, but there are currently over 100 other kernels that you can also use.
Free Bonus: 5 Thoughts On Python Mastery, a free course for Python developers that shows you the roadmap and the mindset you’ll need to take your Python skills to the next level.
Getting Up and Running With Jupyter Notebook
The Jupyter Notebook is not included with Python, so if you want to try it out, you will need to install Jupyter.
There are many distributions of the Python language. This article will focus on just two of them for the purposes of installing Jupyter Notebook. The most popular is CPython, which is the reference version of Python that you can get from their website. It is also assumed that you are using Python 3.
Installation
If so, then you can use a handy tool that comes with Python called pip to install Jupyter Notebook like this:
The next most popular distribution of Python is Anaconda. Anaconda has its own installer tool called conda that you could use for installing a third-party package. However, Anaconda comes with many scientific libraries preinstalled, including the Jupyter Notebook, so you don’t actually need to do anything other than install Anaconda itself.
Starting the Jupyter Notebook Server
Now that you have Jupyter installed, let’s learn how to use it. To get started, all you need to do is open up your terminal application and go to a folder of your choice. I recommend using something like your Documents folder to start out with and create a subfolder there called Notebooks or something else that is easy to remember.
Then just go to that location in your terminal and run the following command:
This will start up Jupyter and your default browser should start (or open a new tab) to the following URL: http://localhost:8888/tree
Your browser should now look something like this:
Note that right now you are not actually running a Notebook, but instead you are just running the Notebook server. Let’s actually create a Notebook now!
Creating a Notebook
Now that you know how to start a Notebook server, you should probably learn how to create an actual Notebook document.
All you need to do is click on the New button (upper right), and it will open up a list of choices. On my machine, I happen to have Python 2 and Python 3 installed, so I can create a Notebook that uses either of these. For simplicity’s sake, let’s choose Python 3.
Your web page should now look like this:
Naming
You will notice that at the top of the page is the word Untitled. This is the title for the page and the name of your Notebook. Since that isn’t a very descriptive name, let’s change it!
Just move your mouse over the word Untitled and click on the text. You should now see an in-browser dialog titled Rename Notebook. Let’s rename this one to Hello Jupyter:
Running Cells
A Notebook’s cell defaults to using code whenever you first create one, and that cell uses the kernel that you chose when you started your Notebook.
In this case, you started yours with Python 3 as your kernel, so that means you can write Python code in your code cells. Since your initial Notebook has only one empty cell in it, the Notebook can’t really do anything.
Thus, to verify that everything is working as it should, you can add some Python code to the cell and try running its contents.
Let’s try adding the following code to that cell:
When I ran the code above, the output looked like this:
If you have multiple cells in your Notebook, and you run the cells in order, you can share your variables and imports across cells. This makes it easy to separate out your code into logical chunks without needing to reimport libraries or recreate variables or functions in every cell.
When you run a cell, you will notice that there are some square braces next to the word In to the left of the cell. The square braces will auto fill with a number that indicates the order that you ran the cells. For example, if you open a fresh Notebook and run the first cell at the top of the Notebook, the square braces will fill with the number 1.
The Menus
The Jupyter Notebook has several menus that you can use to interact with your Notebook. The menu runs along the top of the Notebook just like menus do in other applications. Here is a list of the current menus:
Let’s go over the menus one by one. This article won’t go into detail for every single option in every menu, but it will focus on the items that are unique to the Notebook application.
The first menu is the File menu. In it, you can create a new Notebook or open a preexisting one. This is also where you would go to rename a Notebook. I think the most interesting menu item is the Save and Checkpoint option. This allows you to create checkpoints that you can roll back to if you need to.
Next is the Edit menu. Here you can cut, copy, and paste cells. This is also where you would go if you wanted to delete, split, or merge a cell. You can reorder cells here too.
Note that some of the items in this menu are greyed out. The reason for this is that they do not apply to the currently selected cell. For example, a code cell cannot have an image inserted into it, but a Markdown cell can. If you see a greyed out menu item, try changing the cell’s type and see if the item becomes available to use.
The View menu is useful for toggling the visibility of the header and toolbar. You can also toggle Line Numbers within cells on or off. This is also where you would go if you want to mess about with the cell’s toolbar.
The Insert menu is just for inserting cells above or below the currently selected cell.
The Cell menu allows you to run one cell, a group of cells, or all the cells. You can also go here to change a cell’s type, although I personally find the toolbar to be more intuitive for that.
The other handy feature in this menu is the ability to clear a cell’s output. If you are planning to share your Notebook with others, you will probably want to clear the output first so that the next person can run the cells themselves.
The Kernel cell is for working with the kernel that is running in the background. Here you can restart the kernel, reconnect to it, shut it down, or even change which kernel your Notebook is using.
You probably won’t be working with the Kernel all that often, but there are times when you are debugging a Notebook that you will find you need to restart the Kernel. When that happens, this is where you would go.
The Widgets menu is for saving and clearing widget state. Widgets are basically JavaScript widgets that you can add to your cells to make dynamic content using Python (or another Kernel).
Finally you have the Help menu, which is where you go to learn about the Notebook’s keyboard shortcuts, a user interface tour, and lots of reference material.
Starting Terminals and Other Things
The Terminal is probably the most interesting of the bunch, as it is running your operating systems terminal in the browser. This allows you to run bash, Powershell, and so on in your browser and run any shell command that you might need to there.
Viewing What’s Running
Also on the home page of your Jupyter server ( http://localhost:8888/tree ) are two other tabs: Running and Clusters.
The Running tab will tell you which Notebooks and Terminals you are currently running. This is useful for when you want to shut down your server but you need to make sure that you have saved all your data. Fortunately, Notebooks auto-save pretty frequently, so you rarely lose data. But it’s good to be able to see what’s running when you need to.
The other nice thing about this tab is that you can go through your running applications and shut them down there.
Adding Rich Content
Jupyter Notebook supports adding rich content to its cells. In this section, you will get an overview of just some of the things you can do with your cells using Markup and Code.
Cell Types
There are technically four cell types: Code, Markdown, Raw NBConvert, and Heading.
The Heading cell type is no longer supported and will display a dialog that says as much. Instead, you are supposed to use Markdown for your Headings.
The Raw NBConvert cell type is only intended for special use cases when using the nbconvert command line tool. Basically it allows you to control the formatting in a very specific way when converting from a Notebook to another format.
The primary cell types that you will use are the Code and Markdown cell types. You have already learned how code cells work, so let’s learn how to style your text with Markdown.
Styling Your Text
Jupyter Notebook supports Markdown, which is a markup language that is a superset of HTML. This tutorial will cover some of the basics of what you can do with Markdown.
Set a new cell to Markdown and then add the following text to the cell:
When you run the cell, the output should look like this:
If you would prefer to bold your text, use a double underscore or double asterisk.
Headers
Creating headers in Markdown is also quite simple. You just have to use the humble pound sign. The more pound signs you use, the smaller the header. Jupyter Notebook even kind of previews it for you:
Then when you run the cell, you will end up with a nicely formatted header:
Creating Lists
You can create a list (bullet points) by using dashes, plus signs, or asterisks. Here is an example:
Code and Syntax Highlighting
If you want to insert a code example that you don’t want your end user to actually run, you can use Markdown to insert it. For inline code highlighting, just surround the code with backticks. If you want to insert a block of code, you can use triple backticks and also specify the programming language:
Exporting Notebooks
When you are working with Jupyter Notebooks, you will find that you need to share your results with non-technical people. When that happens, you can use the nbconvert tool which comes with Jupyter Notebook to convert or export your Notebook into one of the following formats:
Jinja is a template engine that was made for Python. Also note that nbconvert also depends on Pandoc and TeX to be able to export to all the formats above. If you don’t have one or more of these, some of the export types may not work. For more information, you should check out the documentation.
How to Use nbconvert
The nbconvert command does not take very many parameters, which makes learning how to use it easier. Open up a terminal and navigate to the folder that contains the Notebook you wish to convert. The basic conversion command looks like this:
Example Usage
Let’s pretend that you have a Notebook named py_examples.ipynb and you want to convert it to PDF. Here is the command you would use to do that:
When you run this command, you should see some output that tells you about the conversion process. nbconvert will display warnings and errors if there are any. Assuming everything goes according to plan, you will now have a py_examples.pdf file in your folder.
The conversion process for the other file types is quite similar. You just have to tell nbconvert what type to convert to (PDF, Markdown, HTML, and so on).
Use the Menu
You can also export your currently running Notebook by going to the File menu and choosing the Download as option.
This option allows you to download in all the formats that nbconvert supports. The benefit of using the menu is that you don’t need to learn the nbconvert at all if you don’t want to. However I recommend doing so as you can use nbconvert to export multiple Notebooks at once, which is something that the menu does not support.
Notebook Extensions
While Jupyter Notebooks have lots of functionality built in, you can add new functionality through extensions. Jupyter actually supports four types of extensions:
This tutorial will focus on Notebook extensions.
What Are Extensions?
A Notebook extension ( nbextension ) is a JavaScript module that you load in most of the views in the Notebook’s frontend. If you are handy with JavaScript, you can even write your own extension. An extension can access the page’s DOM and the Jupyter JavaScript API.
Where Do I Get Extensions?
How Do I Install Them?
This only installs the extension but does not make it active. You will need to enable an extension after installing it by running the following:
You may need to restart your Jupyter Notebook kernel to see the extension.
There is a nice meta extension called Jupyter NbExtensions Configurator that is worth getting for managing other extensions. It allows you to enable and disable your extensions from within the Jupyter Notebook’s user interface and also shows all the currently installed extensions.
Conclusion
The Jupyter Notebook is quite useful not only for learning and teaching a programming language such as Python but also for sharing your data.
You can turn your Notebook into a slideshow or share it online with GitHub. If you want to share a Notebook without requiring your users to install anything, you can use binder for that.
Google and Microsoft both have their own version of the Notebook that you can use to create and share your Notebooks at Google Colaboratory and Microsoft Azure Notebooks respectively. You can browse really interesting Notebooks there as well.
Project Jupyter recently launched their latest product, JupyterLab. JupyterLab incorporates Jupyter Notebook into an Integrated Development type Editor that you run in your browser. You can kind of think of JupyterLab as an advanced version of Jupyter Notebook. JupyterLab allows you to run terminals, text editors and code consoles in your browser in addition to Notebooks.
As always, it is best to try out a new piece of software yourself to see if it suits you and is worth using. I encourage you to give Jupyter Notebook or JupyterLab a spin and see what you think!
Further Reading
If you want to learn more about Jupyter Notebook, you can take a moment and read their excellent documentation.
For more information on Integrated Development Environments, you might want to check out the following articles:
Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with the written tutorial to deepen your understanding: Using Jupyter Notebooks
Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.
About Mike Driscoll
Mike has been programming in Python for over a decade and loves writing about Python!
Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:
Master Real-World Python Skills With Unlimited Access to Real Python
Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:
Master Real-World Python Skills
With Unlimited Access to Real Python
Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:
What Do You Think?
What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.
Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal. Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!
Related Tutorial Categories: intermediate tools