简体   繁体   English

Pandas:AttributeError:模块“csv”没有属性“excel”

[英]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.当我运行pandas时它会出现。我不知道哪里错了,我无法制作数据表。

  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.你在某个地方有一个 csv.py 文件,python 认为它是 csv 模块。 I was able to recreate your stack trace by creating a csv.py file in the same directory as my primary script.通过在与我的主脚本相同的目录中创建一个 csv.py 文件,我能够重新创建您的堆栈跟踪。


Fix: remove the extra csv.py in your path of execution.修复:删除执行路径中额外的 csv.py。 IE either in your directory or find a csv.py file that isn't the module and rename/delete it. IE 在您的目录中或找到一个不是模块的 csv.py 文件并重命名/删除它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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