Python pip
A package that does not come with the language is added with pip. The command on this page is pip install requests. You type that line in the terminal. You do not save it inside the program file. requests is a package other people wrote. math and random are not like that. Those two already come with the language, so this page does not install them. pip is the tool that fetches requests onto the machine. The import line comes later, and it is not this command.
pip install requests
The terminal is where this line runs. When the install works, requests is then on the machine. You do not get a screen of 2 or of 3. There is no die here, and nothing is lifted. The same three words inside a program file stop before anything is installed. The name of that stop is SyntaxError. None is not written in its place. The file does not continue, and requests is not fetched. install is a word the terminal understands. It is not a name you defined in a program.
A finished install does not write import requests for you. You still write that import in the program, after the package is on the machine. This page does not run anything inside requests, and it does not read a page from the network. math stays the module that already comes with the language. You do not run pip install math to get it. The math from the earlier pages is already on the machine.
import requests stops when that package is not on the machine. The name of the stop is ModuleNotFoundError. That import line is not the command above. None is not written, and the program does not go on. math does not stop that way. math is already in the language, so the import finds it.
The next page is a separate environment for each project. This page only adds the one package requests, and only by typing pip install requests in the terminal.
One command in the terminal
pip install requests is typed in the terminal, not in the program file. The same words in a program file stop as SyntaxError. math already comes with the language. A missing requests stops as ModuleNotFoundError. You still write import requests yourself. The next page is a separate environment for each project.
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top