How to run Python code on Chromebook

2

In the era of Machine Learning and AI, the programming language Python has been the driving element for many of the innovations. For programmers, Linux is usually the first priority due to its flexibility. What if you have a Chromebook and would like to run a couple of Python codes? Well. there is a workaround to do so.

how to use python on chromebook

Must See: How To Split Screen on Chromebook

In this article, we’ll discuss how to run Python on a Chromebook powered by ChromeOS. You have to initially set up a Linux Environment which in case if you don’t know how to, go through the guide given below.

Skip to II procedure, if already set up a Linux Environment.

I. Setting Up Your Linux Environment

This step may or may not involve some settings and features you may not have used before. In order to run many of the popular programs or IDE’s, we need to have Linux deployed so we can make use of a Linux terminal. The terminal then will be used to download languages, libraries, and IDEs (Integrated Development Environments).

So, without any further ado, let’s dive in!!! This is going to be an interesting guide.

  1. Tap or click on the gear icon present in the taskbar to open the “Settings” menu. Couldn’t find it? Tap on your clock to find the gear to open the “Settings”.how to run python code on chromebook
  2. It’s always good to make sure the Chromebook is up to date before proceeding. If not updated, go to the settings menu and find the “About Chrome OS” option.how to run python code on chromebook
  3. Tap on the “About Chrome OS” >> “Check for updates” button. Tap “Check for updates” to install the latest updates if any to your Chromebook.how to run python code on chromebook
  4. Then go back to the main settings menu, where you will see a little penguin vector graphics next to an option that reads “Linux (Beta)”.
  5. Tap the “Linux (Beta)” menu item.how to run python code on chromebook
  6. The Linux Beta will open a section: “Linux – Run Linux tools, editors, and IDEs on your Chromebook”.
  7. Tap the “Turn on” button to switch this setting on.how to run python code on chromebook
  8. A toast will appear asking your permission to install Linux. Tap the “Install” button.how to run python code on chromebook
  9. Sip a coffee or tea, sit back relaxing for a while. Let the Linux installs on your computer.how to run python code on chromebook
  10. Once completed, a Linux terminal will open on your computer. yourusername@penguin:~$
    python on chromebook
  11. Yes, it’s done. To get all the new features, let us search for updates to any current packages and dependencies by typing sudo apt-get update. The terminology sudo, a command basically means “superuser do”, which tells the terminal that we are the superuser and that we have the permission to run this command.

II. Python Installation Troubleshooting

  1. To know which version of Python 3 you have! We can do this by typing the command python3 -V into your terminal window. Note, you should type only python3 -V and not python -V! Typing python will check the Python 2 version which does not come preinstalled.

    yourusername@penguin:~$ python3 -V
  2. Once executed, it should display your Python 3 version.

    yourusername@penguin:~$ python3 -V Python 3.7.3
  3. If it didn’t output any string or version (or mostly if you input python instead of python3), you will see something like:

    yourusername@penguin:~$ python3 -V -bash: python3: command not found

To download a new Python version on your machine, continue to the “Installing a New Python Version” section. If you already have the version of Python you want to be installed on your machine, skip “Installing a New Python Version”

III. Updating Python Version

If you need to have a specific version of Python3, you may check the below section.

Suppose that we have Python 3.7.3, and we need the latest Stable Release Python 3.8.8. To do that…

      1. You may download the Python 3.8.8 source file by using the wget command in the terminal or from Python.org’s source page. We recommend the former; wget.

        Using wget command

        First, you’ll need to move into the /usr/src folder in your terminal. Then, when using the wget command, you would change the Python version to match the one you are trying to download:

        yourusername@penguin:~$ cd /usr/src
        yourusername@penguin:/usr/src$ sudo wget https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tgz

    That’s it, you have successfully set up Linux Environment and installed the necessary Python collaterals. Now you can make use of any IDE, coding environment such as Visual Studio, Jupiter or directly code using the Linux Terminal.

Also Read: Google Tweaks Start Page of Incognito Mode for Chrome

If not able to code, do let us know in the comments.

2 COMMENTS

  1. Great article! I just did the same ony Chromebook. It worked great, and even loaded ATOM editor with scripts package to run python3 code in the editor.
    The Chromebook is coming of age. I just loaded Anaconda, OMG….the sky’s the limit

LEAVE A REPLY

Please enter your comment!
Please enter your name here