What you will need
- A computer (PC/Mac/Linux/Raspberry Pi)
- An internet connection
Software
- Python 3
- requests Python module
How to install Python 3
If Python 3 or IDLE isn’t installed on your computer, follow the installation instructions below for your operating system:
Microsoft Windows
It is recommended that you install Python via the Microsoft Store. If this is not possible, you can also use a Python installer from www.python.org.
Microsoft Store (recommended)
-
Click the Get button to download and install Python 3.8.
- Python 3.8 will be downloaded and installed. Progress will be shown in the notification bar.
- When the installation process is complete, a notification will appear.
Python installer
-
Open your web browser and navigate to www.python.org/downloads.
-
On this web page, you will see a button to install the latest version of Python 3. Click the button, and a download will start automatically.
- Click on the
.exe
file to run it. (It will have been saved in yourDownloads
folder, or wherever your computer saves downloaded files by default.)
- In the dialogue box that opens, it is important that you first tick the box next to Add Python 3 to PATH.
- Click on Install Now and follow the installation guide. The setup process will take a little time.
- Once the setup is complete, click on Done, and then close your web browser. Now, you can go to the Start menu to open IDLE.
macOS
-
Open your web browser and navigate to www.python.org/downloads.
-
On this web page, you will see a button to install the latest version of Python 3. Click the button, and a download will start automatically.
- Click on the download in the dock to start the installation process.
- Click on Continue and follow the installation guide. The installation may take a little time.
-
When the installation process is complete, click on Close.
-
Open IDLE from your Applications.
Raspberry Pi OS and other Linux (Debian-based) distributions
Most distributions of Linux come with Python 3 already installed, but they might not have IDLE, the default IDE (interactive development environment), installed.
Use apt
to check whether they are installed and install them if they aren’t.
- Open a terminal window and type:
sudo apt update
sudo apt install python3 idle3
This will install Python 3 (and IDLE), and you should then be able to find it in your Application menu.
You can use pip
to install the requests
module.
Installing Python modules with pip
Installing Python modules with pip
pip
or pip3
is a command line tool for installing Python 3 modules.
Modules can be downloaded as packages from the Python Package Index and installed on your computer automatically.
To install a module, use the pip3 install name_of_module
command, replacing name_of_module
with the module you wish to install.
Follow the instructions below for your operating system.
Raspberry Pi
-
Open a terminal window by clicking Menu > Accessories > Terminal.
-
Enter this command to install a module:
sudo pip3 install name_of_module
If you experience problems, have a look at our guide Using pip on Raspberry Pi.
Windows
- Open a command prompt by clicking Start > Windows System > Command Prompt, or by typing ‘command’ into the start menu’s search bar.
- Enter this command to install a module:
pip3 install name_of_module
If you experience problems, have a look at our guide Using pip on Windows.
macOS
-
Open a terminal window by clicking Applications > Utilities > Terminal, or by typing ‘terminal’ into the desktop’s search bar.
-
Enter this command to install a module:
pip3 install name_of_module
Linux
-
Open a terminal window.
-
Enter this command to install a module:
sudo pip3 install name_of_module
Troubleshooting installation issues
There is comprehensive documentation for pip at pip.pypa.io which will help you with troubleshooting. Here are a few of the common issues, to help you identify problems.
Installation issues
If the installation of a package fails you may see an error message similar to these:
Could not find a version that satisfies the requirement <package-name (from versions: )>
No matching distribution found for <package-name>
The most common source of these errors is a misspelled package name.
You should also check that you are using the package name and not the module name. e.g. the package name for PIL (Python Imaging Library) is pillow
and not PIL
.
Module import issues
If the package installs but an error occurs when you try to import the module, check the following:
-
Which version of Python pip is installing packages into?
If you have multiple versions of Python on your computer, pip might be installing modules for a different version than the one your program is using.
It may be a case of using the right version of the pip command, make sure you are using
pip3
. -
Is the package included in your package list?
You can use the following command to list all the Python packages you have installed.
pip3 list
Upgrading a package
When you install a Python package that is already on your computer, it will not update it to the latest version.
Use this command to update a Python package to the latest version:
pip3 install --upgrade name_of_module
Uninstalling a package
Use this command to uninstall a Python package:
pip3 uninstall name_of_module