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.
Thank you
5 Answers
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 Python has been added to PATH
Then, to install pandas, just simply do:
$ pip install pandas 2you can install using pip
pip install pandas
I think the above answers are very well put already. just 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 terminal
2.type pip install pandas
3.restart your visual studio code
0For anyone else in a similar situation, I'd recommend following along with this VS Code official tutorial.
It guides you to use Conda instead of Pip, and setup a Python environment, along with installing various packages like Pandas, Jupyter, etc.
For example, after installing the Python extension for VSCode and Miniconda or Anaconda:
conda create -n myenv python=3.9 pandas 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