Python Forum

Full Version: pip install requests doesnt work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello guys,
I am total newbie in python and I want to try it.

So first I run Terminal (or at least I think this is terminal) > python.exe
Then I use pip install requests and that's it :D I've receive this error>

File "<stdin>", line 1
pip install requests
^^^^^^^
SyntaxError: invalid syntax

and the question is why? Where is the catch?
pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python. So you have to run the command line. If you are using windows open the menu and type CMD, on mac click the Launchpad icon in the Dock - type Terminal in the search field, then click Terminal , on linux directly pressing [ctrl+alt+T]
VadimCr - thanks for help!

but when I run cmd and write in there pip install requests it comes like this "'pip' is not recognized as an internal or external command,
operable program or batch file."

and of course, I forgot to write I am using windows :)
Check this link on how to install pip.
Seems like you haven't installed Python the right way, and you haven't defined the path for your pip! There are a couple of methods to fix this issue, all of them are described here https://www.stechies.com/pip-not-recogni...l-command/
You can reinstall Python but do not forget to click Add Python 3.9 to the PATH
yes VadimCr! That was it! Thank you! :)

(I have to say because of your post - about cmd - I've tried install python on second PC where exactly I check that button .. and voala :D anyway, thank you veru much! now I can study again)
(Apr-20-2022, 08:07 AM)misodca Wrote: [ -> ]yes VadimCr! That was it! Thank you! :)

(I have to say because of your post - about cmd - I've tried install python on second PC where exactly I check that button .. and voala :D anyway, thank you veru much! now I can study again)

Happy I was able to help you! Good luck on studying
The error you're encountering is because you're trying to run the pip install requests command directly within the Python interpreter (Python REPL). However, pip commands are meant to be executed in the terminal or command prompt, not within the Python interpreter.

To install packages using pip, you need to open a terminal or command prompt window first, and then run the pip install requests command there.

Here are the steps you can follow:
  1. Open a terminal or command prompt window (not the Python interpreter).
  2. Type python and press Enter to start the Python interpreter. You should see the Python prompt >>>.
  3. At the Python prompt, you can now import the requests module and use it in your code.
    import requests
    # Use the requests module here
  4. When you want to install the requests module (or any other package), exit the Python interpreter by typing exit() and pressing Enter.
  5. Now, in the terminal or command prompt window, run pip install requests to install the package.
  6. After the installation is complete, you can start the Python interpreter again and import the requests module without any errors.
Remember to run pip install requests in the terminal or command prompt window, not within the Python interpreter.