hi guy!
I started learn python with pandas , but now, i get the trouble so i cant understand what i should do with this trouble

File "C:\Users\Administrator\site-packages\Ver6.py", line 3, in <module>
      abc = pd.read_csv('book2.csv')
AttributeError: module 'pandas' has no attribute 'read_csv' 

Plz , someone help me coz i cant find the way to fix it !

Dani AI

Generated

Seeing module 'pandas' (namespace) is the key clue. It means Python is finding a top-level directory named pandas on your sys.path (without an init.py), so you are importing a namespace package rather than the real pandas distribution. That prevents attributes like read_csv from existing.

Practical fixes:

  • Check for shadowing in your project and user folders. Rename or remove any file/folder named pandas or pandas.py (and its .pyc/.pyo, pycache) in your workspace and on PYTHONPATH. Also ensure your script is not named pandas.py.
  • Verify which interpreter and package pandas you are using. From the same interpreter that runs your script:
    • python -c "import sys; print(sys.executable); import pandas; import inspect; print(getattr(pandas,'__file__','<namespace>')); print(pandas.__version__)"
      If you see <namespace>, something on sys.path is shadowing pandas.
    • python -m pip show pandas (or pip show pandas) to confirm it is installed for that interpreter.
  • Reinstall cleanly once shadowing is resolved: python -m pip install --upgrade --force-reinstall pandas (or conda install -f pandas if using conda).
  • If you still see a circular import error, audit your own modules for imports that reference each other and avoid importing application code at module top-level; move such imports inside functions or refactor modules.

Docs: pandas.read_csv, Python import system, Circular imports FAQ.

Recommended Answers

All 7 Replies

Try print(pd) to see where this pandas comes from.

commented: ncountering same error as AttributeError: module 'pandas' has no attribute 'read_file' +0

I try print(pd) and it apeared :

<module 'pandas' (namespace)>   

and i dont know how to use it !!!

This is annoying. Mine says

print(pd)
<module 'pandas' from '/usr/local/lib/python3.4/dist-packages/pandas/__init__.py'>

I don't understand where your pandas module comes from. Can you try

print(pd.__file__)

Also is there a file named pandas.py or pandas.pyc in your file system, or a directory named pandas.

AttributeError : 부분적으로 초기화 된 모듈 'pandas'에 'read_csv'속성이 없습니다 (대부분 순환 가져 오기로 인해) ㅇ이 말을 도저히 이해를 할수가 없어요어떡해해야하

English translation from google

I can't use 'read_csv' in 'pandas' because it's too slow (I can't read it properly)

The above non-English post got automatically flagged by our spam bot, but in translating it, I realized it seemed to be a legitimate post.

I’ve released it and unbanned the author. Sorry about that. I do realize this is an old discussion.

For future notice, we are meant to be an entirely English-only community.

commented: what it means? +2
commented: So true +0
commented: So what does it mean? +0
commented: Encountering same error as AttributeError: module 'pandas' has no attribute 'read_file' +0

So sorry for being 3 years late here.

It means:

AttributeError: Partially initialized module 'pandas' has no attribute 'read_csv' (most likely due to circular import) I can't figure this out, what should I do?

I downloaded a sample csv file, and installed pandas in Visual Studio, Python 3.9, 3.11 with the command prompt: python -m pip install pandas

(workspace directory: C:\Users\toneewa\nasa\repos\read_py_file)
CD C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64
python -m pip install pandas
This runs fine:

import pandas as pd
#shows all
#pd.set_option('display.max_rows', None)
#pd.set_option('display.max_columns', None)
df = pd.read_csv('people.csv')
print(df)

    Index          User Id  ... Date of birth              Job Title
0       1  88F7B33d2bcf9f5  ...    1945-10-26        Games developer
1       2  f90cD3E76f1A9b9  ...    1910-03-24         Phytotherapist
2       3  DbeAb8CcdfeFC2c  ...    1992-07-02              Homeopath
3       4  A31Bee3c201ef58  ...    2017-08-03      Market researcher
4       5  1bA7A3dc874da3c  ...    1938-12-01     Veterinary surgeon
..    ...              ...  ...           ...                    ...
95     96  5eFda7caAeB260E  ...    1954-07-30      Software engineer
96     97  CCbFce93d3720bE  ...    1932-04-29              Barrister
97     98  2fEc528aFAF0b69  ...    1994-12-28         Police officer
98     99  Adc7ad9B6e4A1Fe  ...    2012-04-12   Broadcast journalist
99    100  b8D0aD3490FC7e1  ...    2016-11-15  IT sales professional

AttributeError: module 'pandas' has no attribute 'read_csv' can mean two or more modules are importing each other. Be sure not to have a local file or folders that match import modules. Change your workspace.

Giving this code a try will point you in the right direction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.