6

I just switched from PyCharm to VSCode, and when I try to pip install X, I get the following message:

pip : The term 'pip' 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
+ pip install discord
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pip:String) [], CommandNotFoun  
   dException
    + FullyQualifiedErrorId : CommandNotFoundException

I already updated the PATH, and when I do "echo %PATH%" on Command Prompt, I get the exact same directory as my PyCharm PATH directory. Why VSCode doesn't work, while PyCharm works flawless?

My PATH on cmd: "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37-32\Scripts"

yucecoder
  • 71
  • 1
  • 1
  • 4
  • Which Python installation you used? If it is official CPython then it should work unless you have customized installation. – Tejas Sarade Apr 19 '20 at 21:04
  • I am using Microsoft's Python extension on VSC, and downloaded the Python directly from python.org if you are asking that. – yucecoder Apr 19 '20 at 21:18
  • And can you open a new command prompt and run pip there? If you can run pip there, then it is problem with VSCode configuration. If you can't run pip in new command prompt then it is problem with PATH environemnt variable. – Tejas Sarade Apr 19 '20 at 21:33
  • Yes, I can do pip install on windows command prompt, but I can't do it on VSCode terminal. – yucecoder Apr 19 '20 at 21:44
  • In that case going through some python settings for VSCode would be useful https://code.visualstudio.com/docs/python/settings-reference . I suspect that ther might be .env file in your VScode workspace loading some different environment variables. – Tejas Sarade Apr 19 '20 at 22:53
  • is it possible if I can use my pip install commands on command prompt, and import the installed packages on VSCode? – yucecoder Apr 20 '20 at 07:25
  • You can do that. But if VSCode can't find pip, then I suspect it can't find some other scripts required for linting and language support too. – Tejas Sarade Apr 20 '20 at 07:55
  • What happens if you set `"terminal.integrated.inheritEnv": false`? – Brett Cannon Apr 21 '20 at 21:43
  • And BTW you are using PowerShell in VS Code, not Command Prompt based on that error message. If things are working under Command Prompt you could consider changing your shell in VS Code to Command Prompt explicitly. – Brett Cannon Apr 21 '20 at 21:44
  • Interestingly enough. Such an important issue. And yet there is really no fix to it. This issue may occur when you use VScode with or without Anaconda. After I have tried all the suggestions or solutions in either github or stack overflow...still to no avail. Please let me know if you have found a solution. Thank you!@yucecoder PS. I also don't know if this has to do windows and VScode in general. I mean it's also nearly impossible to uninstall vscode from terminal. – Chen Lizi Apr 25 '21 at 01:49

2 Answers2

4

Try using python -m pip instead of pip.

wakonda56
  • 106
  • 4
  • That looks strange ... Did you install pip while installing python from python.org ? (it's optional). Because your error isn't due to VSC (python and pip don't depend of your editor), but to the fact that pip ins't installed or referenced in your PATH. – wakonda56 Apr 19 '20 at 21:29
  • I just tried, and I can do pip install on windows command prompt, but I can't on VSCode terminal. – yucecoder Apr 19 '20 at 21:45
  • I found [this thread](https://stackoverflow.com/questions/23708898/pip-is-not-recognized-as-an-internal-or-external-command), it possibly can help you. – wakonda56 Apr 19 '20 at 21:48
  • My PATH is already like the one that is a solution for that thread. But I will make a better look tomorrow, maybe I am missing some details. – yucecoder Apr 19 '20 at 22:48
  • 1
    "python -m pip" on visual studio terminal helped me. Thanks @wakonda56 – Jnana Mar 23 '21 at 06:22
0

If you have a conda environment setup then try,

conda install pip

It worked for me at least.

Little Bobby Tables
  • 3,724
  • 4
  • 25
  • 43