My goal was to find a lightweight laptop for communication, written content creation, and web development. The promise of installing Android Apps, access to Linux, and the fun of trying something new was too much to pass up on. I ended up with a Google Pixelbook; it’s gorgeous and it’s living up to the hype, albeit after some bumps and bruises. I wanted to share my experiences and hopefully you can avoid some of the tribulations I endured.

In this entry I go through setting up Python for development on a Google Pixelbook. Be sure to check out the first entry in my diary series—Pixelbook Diary #1: Getting Started

Python is Already Installed

Wait, what? Assuming you’ve enabled Linux apps, if you hop into the terminal and type python3 --version you’ll notice that you already have Python installed. So why write this article? Because there’s more to do before diving into development and this is a compilation of my lessons learned more than anything else.

Although Python is already installed we don’t have a way of managing Python modules. Additionally, we’ll want to set up virtual environments so that each project has its own self-contained set of modules to control the version of everything.

Installing PIP

PIP—short for Pip Installs Packages—is the Python version of Linux’s apt or Node’s npm. The first step in getting Python up and running is installing this package manager. Since we’re working with Python3, we’ll install the appropriate version:

sudo apt install python3-pip -y

To confirm the installation type pip3 --version and ensure you have a response. 

Installing Python Virtual Environment

A virtual environment is a way of keeping a local “virtual” environment that has its own scope in terms of modules and packages. This is useful if you want to develop for a specific version of Python. Maybe you need Python 2.7 for a forked repo or you need two different versions of the same module. The installation is very similar to pip:

sudo apt install python3-venv -y

If you’ve done some online searching and reading you may have learned that python virtual environment comes with Python 3.5+, but this is not the case with Chromebooks, which is a Debian environment

Creating a Virtual Environment

We’re all set, time to get to work. To create a virtual environment we’ll use the module venv along with the directory to create the virtual environment in. In this tutorial we’re going to create a directory named python that will then have a directory named my-first-app which will be our virtual environment.

python3 -m venv ~/python/my-first-app

You won’t see any sort of confirmation that the virtual environment has been made, you also shouldn’t see any errors. Let’s go into the directory and check for directories and files.

cd ~/python/my-first-app

You should see a bunch of directories and files including the bin, include, and lib directories. The final thing to do is activate our virtual environment.

source bin/activate

Your command prompt should now start with the environment name in parenthesis (my-first-app). From this point, any modules installed with pip3 will belong to this virtual environment and leave your global installation unaffected. If you want to install a module globally, turn off your virtual environment by typing deactivate at the command line and see the command prompt return to normal. Now go ahead and install your module with pip as normal.

I hope this tutorial was helpful for you, I continue to love my Pixelbook and ChromeOS as a portable business machine.