3

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'
Underoos
  • 4,708
  • 8
  • 42
  • 85
xiu li
  • 31
  • 3

1 Answers1

3

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. I.E. either in your directory or find a csv.py file that isn't the module and rename/delete it.

  • I don't have a csv.py file in my folder, and this is the only answer in every forum out here. – julian joseph Oct 16 '20 at 11:25
  • @julianjoseph have you checked your path for a csv.py? You could further isolate the issue by making a virtualenv and avoid a csv.py from another lib making issues. Assuming the same stack trace then my assumption is a csv.py that isn’t obvious. – Lauro Perez Jr Oct 16 '20 at 15:06
  • so apparently having any .csv file in the same directory also causes an issue. When I removed a constants file saved as .csv to another folder, I was able to resolve this error. – julian joseph Oct 19 '20 at 06:36
  • 1
    @julianjoseph good to know if someone else has a similar. Good luck! – Lauro Perez Jr Oct 19 '20 at 14:30