How do I install pandas into Visual Studio Code?

Question:

I want to read an Excel CSV file, and after researching, I realized I need to import pandas as pd. Is there a way to install it into the Visual Studio Code?

I have tried typing import pandas as pd, but it shows a red line. I’m still new to Python.

Asked By: programmingnoob

||

Answers:

You can install using pip:

pip install pandas

Answered By: George Imerlishvili

As pandas is a Python library, you can install it using pip – the Python’s package management system. If you are using Python 2 >=2.7.9 or Python 3 >=3.4, pip is already installed with your Python. Ensure that the Python executable’s location has been added to PATH.

Then, to install pandas, just simply do:

pip install pandas
Answered By: meobilivang

I think the previous answers are very well put already.
I am just going to add to that.

Windows:

  1. open cmd

  2. type python -m pip install pandas

  3. restart your Visual Studio Code

Linux or macOS:

  1. open a terminal

  2. type pip install pandas

  3. restart your Visual Studio Code

Answered By: user16053699

For anyone else in a similar situation, I’d recommend following along with this Visual Studio Code official tutorial: Data Science in Visual Studio Code tutorial

It guides you to use Conda instead of Pip, and set up a Python environment, along with installing various packages like Pandas, Jupyter, etc.

For example, after installing the Python extension for Visual Studio Code and Miniconda or Anaconda:

conda create -n myenv python=3.9 pandas
Answered By: atlas_scoffed

You need to start off by installing Anaconda in order to create an environment for Pandas; you can manage this environment with Anaconda.
Go to your terminal then run conda create -n myenv python=3.9 pandas jupyter seaborn scikit-learn keras tensorflow. It will create environments for all of the libraries mentioned above.
PS : this is an old post, please check python’s latest version

After that click on your Kernel1 (top right) and chose the environment that is associated with Anaconda

Answered By: aziz bali

I also had the same question. As a newbie, I did not understand the answer. Perhaps these notes will help others in the same boat.

You need to type this into command prompt (not visual studio or python): pip install pandas

Before you do that, you must "Ensure that Python has been added to PATH". This did not make sense to me, but there are pages on this if you Google.

Also useful to know: CMD and Terminal = Command Prompt (please correct me if that’s not true).

Answered By: KymBo

In the terminal on Visual Studio Code, check and make sure the Python interpreter is installed:

py -3 --version

Then you can install libraries with:

py -m pip install *packagename*

This was a simple solution I came up with since the others weren’t working on my system.

Answered By: aaronrod
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.