0

I am new to Python and I have been stuck on a problem for some time now. I recently installed the module pandas and at first, it worked fine. However, for some reason it keeps saying

AttributeError("module 'pandas' has no attribute 'read_csv'").

I have looked all over StackOverflow and the consensus is that there is likely another file in my CWD with the same name but I believe I don't.

Even if I create a new project and call it, for example, Firstproject.py, and immediately import pandas as pd, I get the error.

I would appreciate the help. I can provide more info if required.

3
  • 1
    I suggest visiting How to Ask in order to get a better insight on how to ask a solid question. Additionally, some code, errors, and a slightly better explanation is necessary in order for others to offer you help (they 1st need to understand what the issue). Hang in there. You'll be great at this. Commented Oct 6, 2018 at 9:48
  • Esketit... pls check answers given below if any of in the help. Commented Oct 6, 2018 at 10:00
  • Edit your Question and show the full Traceback Commented Oct 6, 2018 at 16:48

6 Answers 6

3

Your problem is this:

The command

import pandas as pd

in your case didn't import the genuine pandas module, but some other one - and in that other one the read_csv() function is not defined.

Highly likely you have in your project directory (or in your current directory) a file with the name "pandas.py".

And - highly likely - you called the pd.read_csv() function in it.

Rename this file, and you will be happy again. (Highly likely.)

Sign up to request clarification or add additional context in comments.

1 Comment

Spot on "Highly likely you have in your project directory (or in your current directory) a file with the name "pandas.py"."
0

Your best bet is to type "pandas" in your console, and you will be able to see where your "pandas" name is originated from:

>>> pandas
<module 'pandas' from '/some-path/site-packages/pandas/__init__.py'>

Comments

0

There might be possibility that you are using this name for your script as read_csv.py hence pandas itself confused what to import, if or csv.py then you can rename it to something else like test_csv_read.py.

also remove any files in the path naming read_csv.pyc or csv.pyc .

5 Comments

Hey pygo this is not the case.
Hey pygo it happens even I use one line of code which is just to import pandas. ie. import pandas as pd
ill upload a screen shot?
@Esketit, sure that will help
Sorry I cant it wont let me but i have this: Backend TkAgg is interactive backend. Turning interactive mode on. AttributeError("module 'pandas' has no attribute 'read_csv'") Stack trace: > File "c:\users(my name was here)\source\repos\what the hell\what the hell\what_the_hell.py", line 1, in <module> > import pandas as pd Loaded 'main' The program 'python.exe' has exited with code -1 (0xffffffff).
0

Here is the solution when you downloaded python its automatically download 32 you need to delete if you don't have 32 and go download 64 and then problem solved :)

Comments

0

In my case, I had installed module "panda" instead of "pandas". I was getting this error, even when there was no conflicting .py files were present in working folder.

Then I recognized my mistake, and then installed package "pandas and problem got resolved.

Comments

0

You might need to update pandas to a later version using the following command:

pip install --upgrade pandas

The read_xml function is only available in pandas versions >= 1.3.0.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.