Reputation: 139
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.
Upvotes: 12
Views: 313546
Reputation: 1
in VS Code (Windows)
press Ctrl+` to open terminal
type commands below
pip install pandas
Upvotes: 0
Reputation: 31
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.
Upvotes: 3
Reputation: 4127
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
Upvotes: 4
Reputation: 21
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).
Upvotes: 0
Reputation:
I think the previous answers are very well put already. I am just going to add to that.
Windows:
open cmd
type python -m pip install pandas
restart your Visual Studio Code
Linux or macOS:
open a terminal
type pip install pandas
restart your Visual Studio Code
Upvotes: 17
Reputation: 96
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
Upvotes: 8
Reputation: 1
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
Upvotes: -1