7

I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)?

I already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.

TCrepalde
  • 133
  • 1
  • 2
  • 8
  • The [Getting Started with Python in VS Code](https://code.visualstudio.com/docs/python/python-tutorial) page says to "use the Command Palette to run **Terminal: Create New Integrated Terminal**". Probably not the news you wanted to hear. – David Cullen Aug 01 '19 at 13:26

3 Answers3

6

You should open the terminal inside the VSCode and install the modules you want. something like

VSCode Snapshot

if that's not you meant, please let me know.

Community
  • 1
  • 1
Mithilesh
  • 155
  • 1
  • 8
  • I've tried to do it but I'm getting an error about the pip version. I'm using a venv for my python projects and on the terminal, my pip version is updated but it isn't on VSCode what is very strange because I'm using this venv as an interpreter on VSCode. Seems to me that the VSCode isn't recognizing the changes I make on venv through the terminal. – TCrepalde Aug 01 '19 at 14:04
  • @TCrepalde what error are you getting? Your question didn't mention a failure in the terminal, just that you wanted a GUI way to do package installs (for which there isn't one by design as VS Code doesn't like doing things via the GUI if it's reasonable to do from the terminal). – Brett Cannon Aug 01 '19 at 19:09
  • @BrettCannon I found out about the problem with the terminal after I post this question... I'm starting with vscode now so it's some problems that I can't identify instantly. My issue now is with the vscode terminal /: – TCrepalde Aug 02 '19 at 14:44
  • Just for the record, I solved the problem with the vscode terminal by editing the json configurations! I forced the vscode terminal to point to the terminal of the system, so now I can install packages right from the vscode. :) – TCrepalde Aug 28 '19 at 13:58
  • I receive the information that 'pip' is not found as a name of cmdlet, a function, a script or an executible programm. I shall check the writing of the name. – Ben Nov 23 '20 at 15:05
  • 1
    @Ben if I understood your problem, I think this question can help you https://stackoverflow.com/questions/23708898/pip-is-not-recognized-as-an-internal-or-external-command#:~:text=You%20need%20to%20add%20the,added%20to%20your%20PATH%20variable. – TCrepalde Nov 25 '20 at 18:50
  • this question has some answers :) Thank you! – Ben Nov 26 '20 at 18:51
2

Unfortunately! for now, only possible way is terminal.

ialam
  • 163
  • 1
  • 7
1
  1. First of all I would advise you to select the current Python version you have. It has been explained here:

VSCode: There is no Pip installer available in the selected environment

  1. Next, you should check is the pip installed in your Python main directory or not, by checking how to do on this website:

https://pip.pypa.io/en/stable/installing/

or this thread

How to use pip with Visual Studio Code

by typing

   py -m pip

in your terminal, like

   C:\Users\m\Desktop\Python> py -m pip

You should have the list of commands and general options which can be used. One of them is install

On the Python library platform, you always have the command to be copied in order to the installation of package you want.

enter image description here

  1. In your terminal, the initial command should look as:

       PS C:\Users\m\Desktop\Python> py -m
    

to which you should append the command prepared on the Python library platform (by copying it and pasting).

   C:\Users\m\Desktop\Python> py -m pip install openpyxl

That's it. The package should be installed in your Python folder, what you will see in the terminal.

  1. If everything is alright, you just need to type

    import openpyxl     #or other package name, which you downloaded
    

and use it!

MKR
  • 743
  • 1
  • 8
  • 19