1

I am trying to import pandas on Python (Linux) but it is giving me the following error:

ModuleNotFoundError
Traceback (most recent call last) in () 1 import pandas as pd ModuleNotFoundError: No module named 'pandas'

Yash
3,5963 gold badges22 silver badges35 bronze badges
asked Sep 30, 2019 at 12:28
3

3 Answers 3

5

try below code to install pandas.

sudo pip3 install pandas

Above code work for me .

answered Sep 30, 2019 at 12:37
Sign up to request clarification or add additional context in comments.

Comments

2

Try installing with this:

pip install pandas

If the install fails due to lacking privilege, do this:

sudo pip install pandas

Note: You may have to use pip3 is your default Python version is 2.X

answered Sep 30, 2019 at 12:48

Comments

1

You should never install Python packages using sudo as it's a potential security risk. Instead, you should install packages in a virtual environment.

Here's how to create and activate a virtual environment using Python's built-in venv module.

Creating the Environment

On Linux/Mac OS

$ python3 -m venv [name of environment]

On Windows

PS> python -m venv [name of environment]

Activating the Environment

On Linux/Mac OS

$ source [name of environment]/bin/activate

On Windows

PS> [name of environment]\Scripts\activate

Once you have your virtual environment active you can install pandas using pip install pandas and import it as usual in your program.

For more information on working with virtual environments read this: How Can You Work With a Python Virtual Environment?

answered Jul 26, 2022 at 12:23

2 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference as the linked page may change.
I've edited the answer to provide more information.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.