Module error when executing Python program


1. Encountered ‘modulenotfounderror: no module named’ xxxxx ‘while executing Python program:

For example:

In the picture, take the ‘requests’ module imported from a third party as an example. This error indicates that the requests module cannot be found. In Python, there are

Modules are built-in (you can use them by importing them directly). Some modules are third-party and can only be imported and used after installation

Installation direct import use will appear the above error!Here’s the fastest solution:

1) Through PIP (Python software package tool) to install the required third-party modules:

Open CMD and input ‘PIP list‘ to check which modules are installed first:

The required requests module is not installed here. Enter:

The PIP install requests command installs the requests module

PS: if the installation has not been successful using this command, please check another article

Use the PIP list command again to check whether the installation is successful

You can see that the requests module we just installed already appears in the list

Run the program again to use the requests module normally