PRACTICAL TUTORIAL

Preparing Your PC for Natural Language Processing

Install Python & Jupyter Notebook, or Use Google Colab Instead

Andre R
5 min readMay 16, 2020
A macbook pro, a cup of coffee, books, glasses, and some plants on top of a white desk.

Nope, we don’t need those really powerful computers/cloud servers. Don’t get me wrong, we will need them for advanced NLP with deep learning techniques and massive datasets, but not now. To be able to code along the articles in this series, you can choose between these two options:

  1. Python 3 and Jupyter Notebook on your own computer: Need installation (very simple, though), no need for constant internet connection, and easily accessible. We will need to download several libraries and tools from time to time to our computers.
  2. Google Colab: No installation, need constant internet connection and limited remote session (12 hours). Some of the most common libraries for machine learning and NLP are already installed.

Of course, you can also read and choose other options recommended by other people. However, for the sake of simplicity, I prefer to just choose one of the two options above because the faster we are done with setup, the faster we can get to learning and coding!

Installing Python on Your Computer

Before moving on to install Python3 to your machine, it is recommended to check whether Python 3 is already installed. Open your Terminal or Command Prompt application, typepython --version, then hit Enter. If it returns a python version of 3.x.x, then you have already installed Python3. However, if it returns a python version of 2.x.x OR an error message implying that the python command is not recognized, then you have to install Python3 to your machine.

Windows

Source: https://www.python.org/downloads/windows/ (May 9, 2020)
  • Search for the Latest Python 3 Release — Python 3.x.x. then click on the link, as shown in the picture above. As of this writing the latest is Python 3.8.2, but you might find a newer version, I recommend to just install the latest release.
  • In the next page, scroll to the bottom and select either Windows x86–64 executable installer for 64-bit or Windows x86 executable installer for 32-bit, depending on your operating system. (Don’t know which Windows version are you running on? Click here to check.)
Source: https://www.python.org/downloads/release/python-382/ (May 9, 2020)
  • After downloading the installer, just run the executable and follow the on-screen instruction. Note that it is recommended to check the box that says Add Python 3.x to PATH as shown to ensure that the interpreter will be placed in your execution path.

MacOS

Install Homebrew (Part 1)

  • Open your Terminal and run brew -v. If your Terminal returns your Homebrew version, then you can proceed to Install Python3 (Part 2). Below is an example of an installed Homebrew, version 2.2.13.
$ brew -v
Homebrew 2.2.13
  • If your MacOS haven’t installed Homebrew, then open your browser and navigate to Homebrew’s web page (https://brew.sh).
  • Copy the command as shown on the home page, then open Terminal and paste the command. Hit enter to run the Homebrew installation.
  • Finally, type and run brew -v. If your Terminal returns your Homebrew version, then you can proceed to Install Python3 (Part 2).

Install Python3 (Part 2)

  • If you have closed the Terminal, open it again.
  • Type and run brew install python3 in your Terminal. This will download and install the latest version of Python. After the Homebrew brew install command finishes, Python 3 should be installed on your system.
  • Just to make sure that the installation is completed, you can check the python and pip (Python package manager) versions by running the following command in your Terminal:
$ python --version
Python 3.x.x
$ pip --version
pip x.x.x from /Users/.../python3.7/site-packages/pip (python 3.x)

Note: When you type and run the above code in your Terminal, be sure not to include the dollar-sign ($) character.

That’s it! Your computer is ready to run Python3 scripts and you are ready to discover the world of machine learning and natural language processing.

Installing Jupyter Notebook on Your Computer

After Python is installed on your computer, it’s time to install Jupyter Notebook. The installation process is pretty straight-forward, open your terminal/command prompt application, then type pip install notebook then hit Enter. Pip will handle the rest.

After installing, go to your preferred directory in terminal (use cd), then type jupyter notebook to run Jupyter Notebook, your browser will open and you are ready to start coding! See the pictures below.

Running Jupyter Notebook from Terminal
Create a new Python 3 notebook
You’re good to go!

You can check the Jupyter’s official documentation here.

Google Colaboratory

If you don’t want to do all the things mentioned above to install Python and Jupyter Notebook on your PC, here is another option, you only need your browser.

Source: https://medium.com/@nanofaroque/google-colab-is-a-goldmine-for-machine-learning-or-deep-learning-enthusiast-894a80b4b349

One of the best thing done by Google, providing a free cloud service based on Jupyter Notebooks that supports free GPU, even TPU. You can use Google Colab to learn and experiment with machine learning using Python without the need to install anything on your computer, all you need is your favorite browser! Check their FAQ page to learn more about it. Meanwhile, we’ll get to the basics here.

Google Colaboratory
  • Click NEW NOTEBOOK to start your online remote Jupyter Notebook session, we are using a free Google Colab so our session could only last for 12 hours max. You can check out Google Colab Pro if you need more, however, we don’t need that for now.
Voilà! You’re ready to start coding Python.

Conclusion

In this article, we have covered the how-to tutorial to get prepared for our long and exciting journey of Natural Language Processing with Python. We have seen, so far, that there are at least two ways of running code in Jupyter Notebook in our computer:

  • Installing Python 3 and Jupyter Notebook in our own PCs, and
  • Running Notebook provided by Google Colab from our browser.

Now that we are ready to move forward in our NLP journey!

--

--

Andre R
Andre R

Written by Andre R

A user・engineer・researcher living in Tokyo, sharing things I picked up along the way.

No responses yet