Before we can interact with the Twitter API, we’ll need to import the following Python packages:
sys- a basic interpreter that can handle low level functions of the computer’s operating system.
operator- a package that allows arithmetic and comparison functions, such as comparing two strings or multiplying two numbers.
requests- a package that makes it easy to make HTTP requests, so we dont have to code any HTTP interactions.
json- the most widely used format for data exchange on the Internet today. This package makes it easier to work with JSON objects in Python.
watson_developer_cloud- the package needed to interact with the Personality Insights API.
These Python packages are dependencies for the
watson-developer-cloud packages we manually installed earlier. Without them, the
watson-developer-cloud packages won’t function correctly.
The packages will also help us directly communicate with the Twitter API and format the results we’ll display to users.
In CelebrityMatch.py, import all of the above packages by typing the following:
import sys import operator import requests import json import twitter from watson_developer_cloud import PersonalityInsightsV2 as PersonalityInsights
Click Run to save your code. Then click Next to continue.