简体   繁体   中英

Module not found error in Python while trying to import pandas

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'

try below code to install pandas.

sudo pip3 install pandas

Above code work for me.

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

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 a virtual environment using Python's built-in venv module.

How Can You Work With a Python Virtual Environment?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM