Introduction to Ipython and Jupyter Notebook

Introduction to Ipython and Jupyter Notebook

Python, IPython and Jupyter Notebook are three different but closely related tools. In short, Python is the programming language itself, IPython is an enhanced version of Python, and Jupyter Notebook is an environment for interactive computing on the Web, using IPython as the default computing core.

Python is a programming language, and CPython is a specific implementation of Python. It is the most commonly used Python interpreter and is the standard interpreter officially released by Python. It is implemented in C language and is often used to execute Python script files or in Execute simple Python code from the command line. When people refer to Python, by default they are referring to the CPython interpreter. [Python official website https://www.python.org/ , official page to download and install Python https://www.python.org/downloads/ ]

IPython

IPython (Interactive Python) is an enhanced interactive Python interpreter. It provides some additional functions and features based on the ordinary Python interpreter, making interactive programming more convenient and efficient. IPython provides a more friendly command line interface, more powerful code editing and auto-completion functions, better error tracking and debugging functions, and a rich extension library. The IPython environment is built on the Python language. To use the IPython environment, you need to install Python first.

The IPython environment has the following characteristics:

Interactive: The IPython environment allows users to enter and execute Python code line by line and see the results immediately. This makes debugging and experimental programming easier.

Auto-completion: The IPython environment has an auto-completion function that can automatically prompt possible methods, attributes, and variables based on the entered code and imported modules.

Command history: The IPython environment records the history of commands entered by the user. You can browse and re-execute previous commands through the up and down arrow keys.

Magic commands: The IPython environment provides a series of special commands, called magic commands, that can perform some advanced operations, such as performance analysis, debugging, graphics drawing, etc.

Rich text output: The IPython environment can display rich output, including graphics, tables, audio and video, etc.

[IPython official website https://ipython.org/ ]

After installing Python, you can use pip, the package management tool that comes with Python, to install IPython.

Open a command prompt window (Windows) and run the following command in the command prompt window [or open a terminal (Mac/Linux) in a terminal] to install IPython:

pip install ipython

Once the installation is complete, you can use the following command to verify that the installation of IPython was successful:

ipython --version

If the IPython version number is displayed, the installation is successful.

After the installation is complete, you can enter the ipython command on the command line to start the IPython environment . You will see a prompt similar to In[1]:, indicating that you can start entering and executing Python code.

Interactive programming: In the IPython environment, you can enter and execute Python code line by line. Just enter the code and hit enter to execute. You will immediately see the output of your code.

Using magic commands: The IPython environment provides some special commands, called magic commands, that can perform some advanced operations. For example, you can use the %run command to run a Python script file, the %debug command to enter debug mode, and the %timeit command to measure the execution time of the code, etc.

Exiting IPython: To exit the IPython environment, you can use the exit command or press the Ctrl + D key combination.

Jupyter Notebook

Jupyter Notebook can also be called Jupyter. Jupyter Notebook is a web-based interactive computing environment that allows users to create and share documents containing live code, visualizations, and text. Jupyter Notebook supports multiple programming languages, including Python, R, Julia, etc. [To use Python, R, Julia and other programming languages ​​​​in Jupyter Notebook, you need to install the corresponding interpreter or environment first. Generally, after installing Python, use the Python package manager (such as pip) to install Jupyter Notebook - run the pip install jupyter command to install Jupyter Notebook. There is no strict order requirement for installing Jupyter Notebook, R, and Julia]. Starting from Jupyter Notebook 5.0, the IPython project has been merged with the Jupyter project, which means that IPython becomes part of Jupyter. Therefore, we now usually use Jupyter Notebook to represent the entire environment, with IPython as the default computing core.

【Jupyter Notebook官方 Project Jupyter | Home

You can use pip to install Jupyter Notebook. Run the following command in a command prompt window to install Jupyter Notebook.

Open a command prompt window (Windows) and run the following command in the command prompt window:

pip install jupyter

You can also check the version number of your Jupyter Notebook by running the following command in a command prompt window or terminal:

jupyter notebook --version

This will display the version number of the installed Jupyter Notebook. If the version number is displayed, Jupyter Notebook has been installed successfully.

After the installation is complete, you can use the jupyter notebook command on the command line to start Jupyter Notebook . This will open a Jupyter Notebook interface (also called a dashboard) running in the browser, allowing you to start writing and executing code.

I won’t go into details about the specific use of Jupyter Notebook. Please refer to https://zhuanlan.zhihu.com/p/32320214

Guess you like

Origin blog.csdn.net/cnds123/article/details/133524069