So you get an error “no module named pandas” and you aren’t sure why its happening? Let’s figure this out.

“no module named pandas” happens because because your current python environment cannot find the pandas library.

Here’s a list of the common reasons why this error occurs:

  • You haven’t installed Pandas
  • Python can’t find where you installed pandas
  • Different python/pandas versions
  • Pandas is not included in your global path
  • Or you might be using a virtual environment and haven’t installed Pandas
No Module Named Pandas - How To Fix

First, a video that walks through this flow chart. Second, more details on each question.

No Module Named Pandas – How To Debug

How to fix No Module Named Pandas:

  1. Do you have Anaconda Installed?

    Anaconda is an amazing python data tool kit. It is used by Data Scientists, Data Analysts, and Programmers alike. This should be your starting point if you are having problems with Pandas.
    Anaconda comes with Pandas + Python already. So if you install it, use the default file locations, then you shouldn’t have a problem importing pandas

  2. Have you installed Pandas?

    If you don’t want Anaconda (step 1), that’s fine. You’ll need to install Pandas yourself. In order to do this, bring up your command prompt and type “pip install pandas“. This will start the pandas installation. You should be good to go after this.

  3. Have you installed pip?

    If you’re getting an error from the command in Step 2, then you’ll need to install pip. Pip is a package manager for python. This is how you’ll install Pandas and any other python package. Pip comes standard with recent versions of python.

  4. Does “pip show pandas” return valid results?

    “Pip show pandas” will display information about your pandas installation. If pandas is installed, and pip knows where to look for it, then you’ll see a pandas version number along with other information. If you don’t, go to step 5

  5. Are you running a virtual environment?

    Virtual Environments are walled-off containers for python. They are how you have tight control over which exact packages are installed and which versions.
    Sometimes you may have Pandas installed in your global environment but not your virtual environment. Make sure to run “pip show pandas” within your virtual env to check.
    If you don’t know what a virtual environment is, then don’t worry about it, you’re likely not running one.

  6. Is Pandas running on a different version of python than you have installed?

    You may have python 2.7 on your computer, but your Pandas package is trying to run python 3. If this is the case you either need to install an older version of Pandas (“pip install pandas=x.xx.x”). Or you need to upgrade your python.

  7. When in doubt, you can start from scratch

    Uninstall any python files you’ve installed, and go download Anaconda. This will start you from scratch with everything you need.

Check out more Pandas functions on our Pandas Page

Official Documentation