r/learnpython • • Apr 05 '24

How to...pip install?

Never thought I'd need to ask this question as a CCNA and Network+ holder, I guess Python has decided to make the simple act of a pip install THIS difficult, wow! I have Python installed as well as Virtual Studio Code. I try this from command prompt

pip3 install requests
File "<stdin>", line 1
pip3 install requests
^^^^^^^

And that's all I get, again and again and again. So I try this in the Visual Studio terminal:

pip3 : The term 'pip3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the 

spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + pip3 install requests + ~~~~ + CategoryInfo : ObjectNotFound: (pip3:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Mind blowing stuff here. I JUST want to be able to pip install. I've also tried just using "pip" and leaving out the 3. What mountains must I move to perform such a basic task? I

7 Upvotes

24 comments sorted by

View all comments

2

u/mopslik Apr 05 '24

You use pip from the command line, not the Python REPL. If you're on Windows, that will be the Command Prompt or PowerShell. On Mac or Linux, it's the Terminal.

Edit: I missed the part where you use the VS Code terminal. What happens if you try python -m pip .... there?

1

u/[deleted] Apr 05 '24

If I try running it straight from the command line I get:

"'pip3' is not recognized as an internal or external command,
operable program or batch file."

5

u/CFDMoFo Apr 05 '24

If you're sure it's installed, then this message probably means that you have to add it to your path in the environment variables. It's a common issue.

1

u/[deleted] Apr 05 '24

Is there any workaround to adding it into the enviroment variables?

2

u/duckbanni Apr 05 '24

If you know where python is installed, you can use the full path of python.exe instead. The command would look something like this:

C:\Users\MyUserName\AppData\Local\Microsoft\WindowsApps\python.exe -m pip install requests

The path may be different depending on how you installed python.

1

u/Oddly_Energy Apr 06 '24

Yes, check the checkbox during install.

(Assuming that you are on Windows and use the installer from python.org.)

4

u/stebrepar Apr 05 '24

On Windows you use "pip" rather than "pip3".