How To Use Python On A Chromebook 

When choosing laptops, professional developers or aspiring students look up the internet for the best laptops suitable for development. A good laptop for programming consists of a big RAM, a high-performing processor, a reliable operating system and a fast storage type. 

In the above-listed qualities, a variety of laptops are available, and Chromebook is one of them. However, due to a slight misconception, Chromebook is often disregarded as not being a good laptop for programming.

However, that’s not true. In fact, due to the recent developments in the Chrome OS, Chromebook has proven to be a fine laptop optimal for programming. But since the OS is different, you might have a hard time running programming software.

In this article, we will be discussing how to build a python programming environment on a Chromebook quickly.

Setting Up A Python Coding Environment  

Before we jump into the process, we mentioned earlier that Chromebook is not famous for programming. That was the truth until recently, when the latest Chromebook version was released with programming functionalities. 

So, if your laptop is an earlier generation than 2019, follow these instructions. If you have the most recent version, which was published after 2019, move directly on to the following heading.

Firstly to run the programs, you will first need to set up a Linux environment. Before that, you must ensure that the version of Chrome OS is the latest one.

  1. Click on the Time panel on your taskbar at the bottom left corner. Then click on the Settings icon.
  2. Click the About Chrome OS on the window to check if any updates are available. If there are, update the OS to its latest version.
  3. Then, go to the main settings and look for the ‘Linux(Beta)’ option. Click on it.
  4. By clicking on it, you will see the following: Run Linux tools option. Click it.
  5. After clicking on the option, you will be greeted with a window asking your permission for installation.
  6. Select the install button and wait till Linux is installed on your Chromebook.
  7. After the installation is completed, you can open the Linux terminal using the following command: yourusername@penguin:~$
  8. Before proceeding to the next step, to ensure that all the packages are up to date, type the sudo apt-get update, which automatically updates the outdated packages and dependencies on your system.

Installing Correct Python Version

Now that you have set up a suitable environment for programming, the next step is to download python. Before that, run the following command on the Linux terminal to know whether python is available on your system or not.

python3 – V

If there is already a python version on your system, the above command will execute the following output:

yourusername@penguin:~$ python3 -V

Python 3.10.5

If no, the command will execute the following:

yourusername@penguin:~$ python3 -V

-bash: python3: command not found

If your system has no pre-installed python package, no worries, you can proceed with downloading one through the following steps:

To download python, there are two ways. Through the wget command or downloading the version from the actual website. 

  1. Using the wget command, whose purpose is to retrieve files from the mentioned URL. First, you must move the files to the  /usr/src folder of the terminal to use that command. 

@penguin:~$ cd /usr/src

@penguin:/usr/src$ sudo wget https://www.python.org/ftp/python/3.10.5 /Python-3.10.5 .tgz

  1. If you prefer to download from the original website, visit Python.org. Choose the latest Linux version to download. After downloading, move the file from downloads to Linux files and then to the /usr/src/ folder with mv command.

@penguin:~$ sudo mv https://www.python.org/ftp/python/3.10.5 /Python-3.10.5 .tgz /usr/src/

  1. Now unzip the downloaded file with the tar command following the -xzf method to extract the files.

yourusername@penguin:/usr/src$ sudo tar xzf Python-3.10.5 .tgz

Now, to ensure that python is actually installed, run the following command.

yourusername@penguin:~$ python3.10 -V

Python 3.10.5 

Now python is installed on the application successfully.

Accessing and Running Python Files

Since you have installed python successfully on the Linux environment, now all that’s left is to access and run the python programs. 

  1. Share the file containing the python files with your “Linux Files” folder by right-clicking on and selecting the “Share with Linux” option.
  2. You can now move the selected files to Linux files and access them from the terminal.
  3. Now you can view the files through the terminal using the ‘ls’ command.

yourusername@penguin:~$ ls

another_program.py  a_program.py

  1. To run the program, use the python command and follow it with the program file.

yourusername@penguin:~$ python3 a_program.py

Hello World!

Choosing a Code Editor

Writing code in a proper code editor is the best option for complex programs. Depending on your project, you may be using IDLE or any other code editors like VS code etc.

IDLE

IDLE is the default development environment for python. It is equipped with the necessary functionalities to run python codes.

  1. First, let’s look into the steps for downloading IDLE in the Linux terminal using the sudo apt-get install.

yourusername@penguin:~$ sudo apt-get install idle3

  1. Then the command will return with a question asking whether you want to install IDLE. Type ‘y’ to affirm.
  2. After the installation is completed, search for IDLE on the search bar. Click on the editor.
  3. You will be welcomed with the Python shell window. Now click the File menu and then the new file.
  4. Now write any program in the shell, open the “Run” menu, and click “Run Module”.
  5. Then output for the program will be released on the shell.

Running a Python Program Using the Chrome Extension

ALT Tag: Running a python program using the chrome extension.

If you find the above process of setting up a Linux environment and installing the necessary python packages, there is a much easier alternative for you. That is using the chrome extension method.

The method is simple,

  1. Go to the chrome web store to download the Python Shell Chrome Extension.
  2. Click on add to chrome to install and add the extension to the browser.
  3. After the extension is installed, click on it to launch it.
  4. A small window will appear where you can write and execute the python code.

The plus for this method is that the python extension comes with support for Python, Ruby, and Javascript. The minus is that, for complex programs, using a code editor would be a much better choice.

The Bottom Line

Which method do you think is the best choice with the different methods discussed? The best option for writing and running advanced python programs is the Linux approach or the code editor. Though the extension method is an effortless choice, it is only suitable for running basic python programs.

Time to learn some coding basics

Are you interested in learning more about software development? If so, then it’s time to learn the basics with Code Institute’s free 5 Day Coding Challenge. All it takes is one hour a day over five days. By the end, you will have built your first ever web page. Register now through the form below. Alternatively, if you want to know more about our Full Stack Software Developer programme, follow this link

Programming & Coding Terms, Defined 

As with any skill, it is essential to familiarise yourself with the fundamental terminologies used in that field before fully committing to practice mode. Understanding coding words can speed up and improve your knowledge of your area. This blog looks at simple definitions for programming and coding terms.    We have provided you with a list […]

Python Projects for Beginners  

Python has recently become one of the most widely used programming languages. Everything from website development to software testing to machine learning uses it. Moreover, both developers and non-developers can use it. Python is a popular, interpreted, object-oriented, high-level, dynamically semantic, and general-purpose programming language. Whether or not they know of it, consumers use many […]

6 Essential Non-Technical Skills A Software Developer Should Have in 2023

Whenever you search “What skills should a developer possess” in Google, you will be responded with tons of results advising you on learning various programming languages, algorithms, and other technical aspects of programming. However, is mastering the art of programming alone enough to land a job? Not necessarily. In this article, we look at some of […]