Raspberry Pi

How to Install IPython on Raspberry Pi

IPython is a command shell that allows users to perform interactive computing in multiple programming languages, especially Python. It has an enhanced interactive environment with many functionalities, including rich media, tab completion, shell syntax and more. It’s different from the previously used Python shell and uses the Jupyter kernel to allow users to work with Python code in Jupyter notebooks.

This article will help users install IPython on Raspberry Pi.

How to Install IPython on Raspberry Pi

Since IPython is a tool used mostly for the Python programming language, Raspberry Pi users can easily install it from Python Package Management (pip). However, before that, ensure pip is installed on your Raspberry Pi system using the following command:

$ pip --version

If pip isn’t installed on Raspberry Pi, use the guidelines here.

After ensuring pip is installed, you can run the following command to install IPython on Raspberry Pi:

$ pip3 install ipython

To confirm IPython is successfully installed on the Raspberry Pi system, follow the below-given command:

$ ipython --version

Run IPython on Raspberry Pi

You can run IPython on Raspberry Pi terminal using the following command:

$ ipython

This opens the Enhanced Interactive Python interpreter on the terminal.

Use IPython on Raspberry Pi

Let’s first create a Python file in a separate terminal using the nano editor through the following command:

$ sudo nano <file_name>.py

Inside the file, add the following Python code for displaying a message on the terminal.

$ print (“Type Message Here”)

Save the file using “CTRL+X”.

Now, at the IPython interpreter, you have to run the Python file using the “run” command as shown below:

run <file_name>.py

The file’s output will display right after you execute the run command.

To check for recently performed activities on the IPython interpreter, you can use the following code:

history

You can also assign the system’s output to a Python variable like the following:

var=!date

Now run the following code to display the time on your system:

var

Similarly, you can also display a message with system command calls by observing the following example:

myvar='Type Message Here'

Now, run the following code with the callout variable you defined in the above code inside the curly brackets:

!echo "{myvar}"

You can also prefix Python variable with $ command to get the similar output of the above example:

!echo $myvar

To learn about IPython in details, you can open its manual in the terminal using the following command:

$ man ipython

Conclusion

IPython is an enhanced interactive command shell for Python with easy configuration, command completion, Jupyter notebook, QT console, and much more. You can easily install it on Raspberry from “pip”. After the installation, you can run IPython with the command “ipython” and start performing Python programming on the terminal through the guidelines mentioned above. For further guidance, you can get help from the IPython manual by opening it on the terminal using the “man” command.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.