tcrepalde
tcrepalde

Reputation: 435

How to install a new python module on VSCode?

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.

Upvotes: 22

Views: 193723

Answers (4)

risha
risha

Reputation: 21

Installing using the 'pip' from within python worked for me.

  1. On the vscode terminal type in python and goto the python prompt

  2. At python prompt:

    import pip

    pip.main(['install', "pandas"]) #this will install pandas in the current environment.

  3. quit python prompt and return to vscode terminal.

Upvotes: 1

Geographos
Geographos

Reputation: 1456

  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!

Upvotes: 10

ialam
ialam

Reputation: 173

Unfortunately! for now, only possible way is terminal.

Upvotes: 4

Mithilesh
Mithilesh

Reputation: 263

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.

Upvotes: 13

Related Questions