Programming in Python on a Chromebook
Programming in Python on a Chromebook
Setting Up Your Python Coding Environment
If you were able to enable Linux on your computer, it should automatically come with Python 3 installed. If you haven’t set up your Linux environment yet, please read theProgramming Locally on a Chromebookarticle before continuing.
Checking Your Python Installation
- Let’s see which version of Python 3 you have! We can do this by typing the commandpython3 -Vinto your terminal window. Make sure you typepython3 -Vand notpython -V! Typingpythonwill check the Python 2 version which does not come preinstalled.yourusername@penguin:~$ python3 -V
- If this worked, it should display your Python 3 version.yourusername@penguin:~$ python3 -V Python 3.7.3If it didn’t work (or if you typed inpythoninstead ofpython3), you will see something like:yourusername@penguin:~$ python3 -V -bash: python3: command not foundTo 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 installed on your machine, skip “Installing a New Python Version”.
yourusername@penguin:~$ python3 -V
yourusername@penguin:~$ python3 -V
Python 3.7.3
yourusername@penguin:~$ python3 -V
-bash: python3: command not found
Installing a New Python Version
If you’re doing a Python 3 off-platform project, you probably don’t need to look at this section! This section is helpful for learners who are trying to code in Python 2 or a specific version of Python 3.
In this example, we have Python 3.7.3, and we’ll be downloading Python 3.8.8. Python 3.8.8 is the Python 3.8 Stable Release according to Python.org.
- You can download the Python 3.8.8 source file by using thewgetcommand in the terminal or fromPython.org’s source page. We suggest usingwgetbut will show both approaches.UsingwgetFirst, you’ll need to move into the/usr/srcfolder in your terminal. Then, when using thewgetcommand, 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.tgzUsing Python.orgIf you want to download the file from the Python.org website instead, you will navigate toPython.org’s source page. You will want to download from theStable Releasecolumn and click the link to get theGzipped source tarballtype of file from the version you want.You will need to move the downloaded file from your “Downloads” folder to your “Linux Files”. Then, you will need to move the file to/usr/src/. You can do this with themvcommand.yourusername@penguin:~$ sudo mv https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tgz /usr/src/
- You will now need to unzip the file and check if it worked! We will use thetarcommand to unzip it.yourusername@penguin:/usr/src$ sudo tar xzf Python-3.8.8.tgzNow, we’ll check if it worked by checking the version! We will need to usepython3.8instead ofpython3since we downloaded Python 3.8.8 in this example.yourusername@penguin:~$ python3.8 -V Python 3.8.8
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
An image showing the current stable releases of Python from Python.org
yourusername@penguin:~$ sudo mv https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tgz /usr/src/
yourusername@penguin:/usr/src$ sudo tar xzf Python-3.8.8.tgz
yourusername@penguin:~$ python3.8 -V
Python 3.8.8
Picking Your Coding Environment
VS Code is a great environment for lots of coding projects, but, depending on which off-platform project you’re doing or what you’re hoping to create, you may want a different coding environment. VS Code can be used to program in many different languages and is very versatile, and we will explain how to install VS Code in this article.
If your off-platform project requiresJupyter Notebook, you can learn how to install that in ourInstalling Jupyter Notebook on a Chromebookarticle.
Installing VS Code
You can follow the below instructions or findinstallation instructions from the VS Code website here.
- It’s recommended that, in addition to runningsudo apt-get update, we install the dependencygnome-keyring. You can do this with the commandsudo apt-get install -y gnome-keyring.yourusername@penguin:~$ sudo apt-get install -y gnome-keyring
- Next, to determine which installation file you should download, we need to figure out whichCPUyour Chromebook has. You can do this with the commanddpkg --print-architecture.yourusername@penguin:~$ dpkg --print-architectureYou will see eitheramd64orarm64.
- Go to theVS Code Download page. The Linux installation section will be underneath the image of the penguin.If you sawamd64when you ran the previous command, click on the button that says “64 bit” in the “.deb” row underneath the image of the penguin.If you sawarm64when you ran the previous command, click the button that says “ARM 64” in the “.deb” row underneath the image of the penguin.
- Open your “Files” on your Chromebook and go to your “Downloads” section. Double-click on the installer to begin the installation.
- A popup will let you know that you’re going to “Install app with Linux (Beta)”. Click “Install” to start the installation. You can press “Okay” to close the installation window.
- Now, you can search for VS Code whenever you’re ready to start coding!
yourusername@penguin:~$ sudo apt-get install -y gnome-keyring
yourusername@penguin:~$ dpkg --print-architecture
Image of Linux download section
Image of the install file in the Downloads folder
An image of the popup saying "Install"
An image of the popup saying "Install"
How Do I Access and Run a File from the Terminal?
You can use your Linux terminal to access files stored in the “Linux files” section of “My files”. To move files you’ve downloaded from Codecademy into this folder there are a few steps:
- Share your “Downloads” folder with your “Linux Files” folder by right-clicking on “Downloads” and then pressing “Share with Linux”.
- Now, you can move your file to “Linux files” and it will be accessible from your terminal!
- You can also view the files in “Linux files” by going to your terminal and using thelscommand.yourusername@penguin:~$ ls move_me.py my_first_program.py
- You can run your program using thepythoncommand. You will writepython3 name_of_file.py(for Python 3) andpython name_of_file.pyfor Python2. If you’re using a different version of python, your command will look a little different.yourusername@penguin:~$ python3 my_first_program.py Hello World!
You must share the folder with the Linux files folder
The file now lives in the Linux files folder
yourusername@penguin:~$ ls
move_me.py my_first_program.py
yourusername@penguin:~$ python3 my_first_program.py
Hello World!
Programming Locally
While there are some limitations toprogramminglocally on your Chromebook, you can still program in many languages.
The following articles will help you set up a specific language or tool on your Chromebook:
- Installing Jupyter Notebook on a Chromebook
- Installing IDLE on a Chromebook
- Web Programming on a Chromebook
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Complete Payment to Unlock Full Guide & Source Code
You are viewing the 30% preview. Join TopCourseAI Pro to unlock the remaining 70% of this article, unblur all code snippets, and gain full access to all 412 technical projects and guides.
Ready to access the complete step-by-step tutorial?
Gain full unhindered access to all 412 technical projects and guides, unblur all source code snippets, and download runnable scripts.
Programming Locally on a Chromebook
Next BlueprintPrompt Engineering 101: Understanding Zero-Shot, One-Shot, and Few-Shot
Related Blueprints & Guides
View all 166 →Android Studio Quick-Start Guide
Android Studio often intimidates beginners, but by learning a few handy shortcuts and getting the lay of the land, we can navigate this powerful development environment with ease.
Developer toolsApache Kafka Tutorial: A Complete Guide for Beginners
Apache Kafkais a well-known distributed event streaming platform designed to efficiently manage real-time data feeds. It was originally developed by LinkedIn in 2011 and later open-sourced. Apache Kafka has gained immens...
Developer toolsBuilding Websites with Wix
Creating a website has never been easier. Previously, making a presentable website meant learning HTML, CSS, andJavaScript. The whole process could take weeks, months, or even years before creating a website that you’re...
Ready to build production-grade AI systems?
Enjoyed this guide? Continue exploring our library of 166+ production blueprints, multi-agent swarms, and autonomous agent systems with 100% unblurred, executable source code.