draperjames / qtpandas

Qt Meets Pandas
MIT License
141 stars 53 forks source link

TestApp is throwing attribute error #12

Closed draperjames closed 7 years ago

draperjames commented 7 years ago

When I run TestApp.py I recieve the following error;

C:\Anaconda3\lib\site-packages\qtpandas\encoding.py:21: UserWarning: Detector.Issues importing libmagic - got an error: [WinError 193] %1 is not a valid Win32 application
  warnings.warn("Detector.Issues importing libmagic - got an error: {}".format(e))
Error in sys.excepthook:
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\qtpandas\excepthook.py", line 32, in excepthook
    tbinfo = tbinfo.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'

Original exception was:
Traceback (most recent call last):
  File "C:\Users\Lenovo\Documents\GitHub\QtPandas\examples\TestApp.py", line 244, in <module>
    widget.setDataFrame( getCsvData() )
  File "C:\Users\Lenovo\Documents\GitHub\QtPandas\examples\util.py", line 37, in getCsvData
    parse_dates=parse_dates
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 498, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 275, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 590, in __init__
    self._make_engine(self.engine)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 731, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1103, in __init__
    self._reader = _parser.TextReader(src, **kwds)
  File "pandas\parser.pyx", line 353, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:3246)
  File "pandas\parser.pyx", line 591, in pandas.parser.TextReader._setup_parser_source (pandas\parser.c:6111)
OSError: File b'C:\\Users\\Lenovo\\AppData\\Local\\atom\\app-1.12.6\\testData/test1.csv' does not exist

I think we need to change decode to encode. It should be compatible with py2/3

draperjames commented 7 years ago

Okay I swapped decode for encode and here is the error message that I get now;

C:\Anaconda3\lib\site-packages\qtpandas\encoding.py:21: UserWarning: Detector.Issues importing libmagic - got an error: [WinError 193] %1 is not a valid Win32 application
  warnings.warn("Detector.Issues importing libmagic - got an error: {}".format(e))
Error in sys.excepthook:
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\qtpandas\excepthook.py", line 42, in excepthook
    msg = '\n'.join(sections)
TypeError: sequence item 6: expected str instance, bytes found

Original exception was:
Traceback (most recent call last):
  File "C:\Users\Lenovo\Documents\GitHub\QtPandas\examples\TestApp.py", line 244, in <module>
    widget.setDataFrame( getCsvData() )
  File "C:\Users\Lenovo\Documents\GitHub\QtPandas\examples\util.py", line 37, in getCsvData
    parse_dates=parse_dates
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 498, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 275, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 590, in __init__
    self._make_engine(self.engine)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 731, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "C:\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1103, in __init__
    self._reader = _parser.TextReader(src, **kwds)
  File "pandas\parser.pyx", line 353, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:3246)
  File "pandas\parser.pyx", line 591, in pandas.parser.TextReader._setup_parser_source (pandas\parser.c:6111)
draperjames commented 7 years ago

I opened this PR#19 to solve the issue and I'll merge the branch when I have it sorted. @zbarge have you had any problems with this? Are you using python2 at all? I think we need to update the .travis.yml file to actually test things correctly b/c right now the thing passes if the project builds.

zbarge commented 7 years ago

Kinda looks like different errors between the two comments. The first is

OSError: File b'C:\Users\Lenovo\AppData\Local\atom\app-1.12.6\testData/test1.csv' does not exist

The next one looks like it could be because the filepath string is formatted as a bytes string instead of a regular (or raw) string. I'll take a look now.

draperjames commented 7 years ago

Actually I meant to close this. With #20.