rosasalberto/mil

Error loading data when installed with pip

jasonzutty opened this issue · 1 comments

>>> from mil.data.datasets import musk1
>>> (bags_train, y_train), (bags_test, y_test) = musk1.load()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/mil/data/datasets/musk1.py", line 7, in load
    return load_data(current_file + './csv/musk1.csv')
  File "/usr/local/lib/python3.7/site-packages/mil/data/datasets/loader.py", line 10, in load_data
    df = pd.read_csv(filepath, header=None)
  File "/usr/local/lib/python3.7/site-packages/pandas/io/parsers.py", line 676, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python3.7/site-packages/pandas/io/parsers.py", line 448, in _read
    parser = TextFileReader(fp_or_buf, **kwds)
  File "/usr/local/lib/python3.7/site-packages/pandas/io/parsers.py", line 880, in __init__
    self._make_engine(self.engine)
  File "/usr/local/lib/python3.7/site-packages/pandas/io/parsers.py", line 1114, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "/usr/local/lib/python3.7/site-packages/pandas/io/parsers.py", line 1891, in __init__
    self._reader = parsers.TextReader(src, **kwds)
  File "pandas/_libs/parsers.pyx", line 374, in pandas._libs.parsers.TextReader.__cinit__
  File "pandas/_libs/parsers.pyx", line 673, in pandas._libs.parsers.TextReader._setup_parser_source
FileNotFoundError: [Errno 2] File /usr/local/lib/python3.7/site-packages/mil/data/datasets./csv/musk1.csv does not exist: '/usr/local/lib/python3.7/site-packages/mil/data/datasets./csv/musk1.csv'

package was installed with pip.

Problem might be a linux vs windows issue, the result of the code:

import os

from mil.data.datasets.loader import load_data

current_file = os.path.abspath(os.path.dirname(__file__))
def load():
    return load_data(os.path.join(current_file, './csv/musk1.csv'))

Isn't putting the necessary file separator between what comes out of current_file and the './csv/musk1.csv'

I would recommend taking out the preceding ./ and replacing the line with return load_data(os.path.join(current_file, 'csv/musk1.csv')), I believe this will work.