简体   繁体   中英

Pandas: AttributeError: module 'csv' has no attribute 'excel'

when I run pandas it will appear.I didn't know where is wrong,and I can't make a data sheet.

  File "C:/Users/27357/Desktop/test.py", line 2, in <module>
    import pandas
  File "C:\python\lib\site-packages\pandas\__init__.py", line 55, in <module>
    from pandas.core.api import (
  File "C:\python\lib\site-packages\pandas\core\api.py", line 24, in <module>
    from pandas.core.groupby import Grouper, NamedAgg
  File "C:\python\lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
    from pandas.core.groupby.generic import (  # noqa: F401
  File "C:\python\lib\site-packages\pandas\core\groupby\generic.py", line 44, in <module>
    from pandas.core.frame import DataFrame
  File "C:\python\lib\site-packages\pandas\core\frame.py", line 88, in <module>
    from pandas.core.generic import NDFrame, _shared_docs
  File "C:\python\lib\site-packages\pandas\core\generic.py", line 70, in <module>
    from pandas.io.formats.format import DataFrameFormatter, format_percentiles
  File "C:\python\lib\site-packages\pandas\io\formats\format.py", line 48, in <module>
    from pandas.io.common import _expand_user, _stringify_path
  File "C:\python\lib\site-packages\pandas\io\common.py", line 512, in <module>
    def UnicodeReader(f, dialect=csv.excel, encoding="utf-8", **kwds):
AttributeError: module 'csv' has no attribute 'excel'

Based off the Stack Trace and some quick googling.

You have a csv.py file somewhere that python is thinking is the csv module. I was able to recreate your stack trace by creating a csv.py file in the same directory as my primary script.


Fix: remove the extra csv.py in your path of execution. IE either in your directory or find a csv.py file that isn't the module and rename/delete it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM