very weird pandas behavior

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Dec 20 21:22:14 EST 2014


ryguy7272 wrote:

> I downloaded pandas and put it in my python directory, then, at the
> C-prompt, I ran this: "pip install pandas"

C-prompt? Are you maybe running Windows? I'll assume so.


> It looks like everything downloaded and installed fine.  Great.


Did pip print any output? What did it say?

In particular, I'm looking to see:

(1) What version of Python pip was using.

(2) Where it put the installed version of pandas.

(3) Is there anything to suggest the installation actually failed?

The nature of the problem suggests to me that you might have two different
versions of Python installed. Is that possible?


> Now, in Python Shell, I enter this:
> import pandas as pd

What version of Python are you using here? Is it the same as the version
used by pip?

Run this:

import sys
print(sys.version)
print(sys.path)


and COPY AND PASTE the output of those two print lines back here.


> I get this error.
> Traceback (most recent call last):
>   File "<pyshell#19>", line 1, in <module>
>     import pandas as pd
> ImportError: No module named pandas


It looks like you are using some sort of IDE. "pyshell"? Although this is a
long-shot, it's not quite impossible that the IDE is at fault. My
recommendation is to run the vanilla Python interactive interpreter and see
if you get the same problem.

I *think* this should work under Windows. At the DOS prompt, enter:

python

If it launches your usual IDE, exit and we'll have to try again. But if it
launches the vanilla Python interactive interpreter, you should see
something like this:

Python 2.7.2 (default, May 18 2012, 18:25:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

(Yours may have a different version number and date, and should say Windows
rather than Linux.)

Type the following:

import pandas

Does that work now?


Enter `quit()` to exit the interactive interpreter, and try again with

python27

python33

python34

What do they do? Anything different from the above?



> Any idea what I'm doing wrong?

I'm 95% sure it will turn out to be version confusion: you have two versions
of Python installed, you used pip to install pandas for version A but then
ran version B.

Otherwise, 3% that the pip installation actually failed, and you just didn't
realise, 1% that it's a problem with the IDE, and 1% something else.



-- 
Steven




More information about the Python-list mailing list