Skip to content

pandas not found when it's supposed to be installed #11604

Closed
@datomnurdin

Description

@datomnurdin

I got this error message. Already installed pandas.

>>> import pandas as pd
Traceback (most recent call last):
  File "analyze_tweets.py", line 9, in <module>
    import pandas as pd 
ImportError: No module named pandas

SOLUTION (by @datapythonista)

This error happens when Python can't find pandas in the list of available libraries. Python has internally a list of directories where it'll look for packages. These directories can be obtained with import sys; sys.path.

In one machine you can (and should) have several Python installations. Meaning that you can have pandas installed in one, and be using another Python installation (this is likely the case here).

In Linux/Mac you can run which python and will tell you which is the Python you're using. If it's something like /usr/bin/python, you're using the Python from the system, which is not a great practice, and rarely used in the Python community.

If you used Python before you may have used virtual environments and pip. While this is fine for many Python projects (e.g. Django), when using data projects (pandas, numpy, tensorflow...) this is discouraged. It's easy that you have installation errors, and also the libraries can run much slower when using pip.

The widely used solution to this problem is to use conda. You can find simple installation instructions for pandas in this document: https://dev.pandas.io/getting_started.html

For more advanced users, installing miniconda, and then manually install pandas (and any other required package) with conda can be preferred (but avoid this if you're starting, since you'll probably have errors of missing dependencies when using many of the pandas features).

Metadata

Metadata

Assignees

No one assigned

    Labels

    BuildLibrary building on various platforms

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions