[Tutor] ModuleNotFound Error

Mats Wichmann mats at wichmann.us
Thu Aug 13 14:33:16 EDT 2020


On 8/13/20 11:25 AM, Schuster, Emily A. wrote:
> Hi Everyone!
> I’ve been trying to install Pandas onto Anaconda. I’ve installed it using both pip and conda, and whenever I try to reinstall it says that the “Requirement has already been satisfied”, so I know Pandas is in there somewhere; however, when I try to “import pandas as pd” in my Python program in IDLE, I get a ModuleNotFoundError: “pandas” does not exist. Why is python/Anaconda not able to access the Pandas library?

We can 100% answer that question: because your paths are wrong.

When a module is known to exist, but Python can't import it, Python is
looking in the wrong place.

Fixing it isn't necessarily as easy as the snap conclusion...

In *general*, if installing using the pip module, do so in a way that
makes sure to use the same Python that you're going to run
(pip-the-standalone-command is associated with *some* Python, but
possibly not with the Python you're intending to use).  So:

python -m pip install pandas

as long as the thing you're intending to use is "python"  (i.e. adjust
this if you're on Windows using the python launcher "py", or on a system
where you're trying to call out a specific version like "python3.7")

You've introduced two complications which makes it harder to answer from
here:

- you're using Anaconda, which also has its own installer.  Did you use
the conda installer? Or did you install using pip?
- you're using IDLE, which from my limited experience with Anaconda, may
not use Python the same way. Perhaps somebody else can help with that
part.


If you're inside IDLE's Python window, you can check the module search
path like this:

>>> import sys
>>> sys.path
[ .... whole bunch of stuff, those are the places that Python will use
to look for what you try to import ]

Do you know where your Pandas module went to?  If you used pip you can
ask this way:

pip show pandas





More information about the Tutor mailing list