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.
- Click on the Time panel on your taskbar at the bottom left corner. Then click on the Settings icon.
- 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.
- Then, go to the main settings and look for the ‘Linux(Beta)’ option. Click on it.
- By clicking on it, you will see the following: Run Linux tools option. Click it.
- After clicking on the option, you will be greeted with a window asking your permission for installation.
- Select the install button and wait till Linux is installed on your Chromebook.
- After the installation is completed, you can open the Linux terminal using the following command: yourusername@penguin:~$
- 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
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.
- 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
- 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/
- 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
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.
- Share the file containing the python files with your “Linux Files” folder by right-clicking on and selecting the “Share with Linux” option.
- You can now move the selected files to Linux files and access them from the terminal.
- Now you can view the files through the terminal using the ‘ls’ command.
- To run the program, use the python command and follow it with the program file.
yourusername@penguin:~$ python3 a_program.py
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 is the default development environment for python. It is equipped with the necessary functionalities to run python codes.
- 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
- Then the command will return with a question asking whether you want to install IDLE. Type ‘y’ to affirm.
- After the installation is completed, search for IDLE on the search bar. Click on the editor.
- You will be welcomed with the Python shell window. Now click the File menu and then the new file.
- Now write any program in the shell, open the “Run” menu, and click “Run Module”.
- 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,
- Go to the chrome web store to download the Python Shell Chrome Extension.
- Click on add to chrome to install and add the extension to the browser.
- After the extension is installed, click on it to launch it.
- A small window will appear where you can write and execute the python code.
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.