【问题标题】:turicreate windows(wsl ubuntu) cannot open csv file for readingturicreate windows(wsl ubuntu) 无法打开 csv 文件进行读取
【发布时间】:2021-02-18 21:00:21
【问题描述】:

我在 Windows 上安装了 wsl Ubuntu 20.04 LTS 版本以使用 turicreate。但是我在使用 csv 文件时遇到了一些问题,我将它从我的下载文件夹移到了 venv 文件夹所在的 /home/user 中。在第一行我 !pip install turicreate 并运行 Requirement already meet 然后导入 turicreate 并运行

sf = turicreate.SFrame(r'people-example.csv')

得到了输出

OSError                                   Traceback (most recent call last)
~/MLvenv/lib/python3.8/site-packages/turicreate/data_structures/sframe.py in _read_csv_impl(cls, url, delimiter, header, error_bad_lines, comment_char, escape_char, double_quote, quote_char, skip_initial_space, column_type_hints, na_values, line_terminator, usecols, nrows, skiprows, verbose, store_errors, nrows_to_infer, true_values, false_values, _only_raw_string_substitutions, **kwargs)
   1093             with cython_context():
-> 1094                 errors = proxy.load_from_csvs(internal_url, parsing_config, type_hints)
   1095         except Exception as e:

cy_sframe.pyx in turicreate._cython.cy_sframe.UnitySFrameProxy.load_from_csvs()

cy_sframe.pyx in turicreate._cython.cy_sframe.UnitySFrameProxy.load_from_csvs()

OSError: Cannot open /home/anagene/people-example.csv for read. Cannot open /home/anagene/people-example.csv for reading

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
~/MLvenv/lib/python3.8/site-packages/turicreate/data_structures/sframe.py in __init__(self, data, format, _proxy)
    825                     url = data
--> 826                     tmpsf = SFrame.read_csv(url, delimiter=",", header=True)
    827                     self.__proxy__ = tmpsf.__proxy__

~/MLvenv/lib/python3.8/site-packages/turicreate/data_structures/sframe.py in read_csv(cls, url, delimiter, header, error_bad_lines, comment_char, escape_char, double_quote, quote_char, skip_initial_space, column_type_hints, na_values, line_terminator, usecols, nrows, skiprows, verbose, nrows_to_infer, true_values, false_values, _only_raw_string_substitutions, **kwargs)
   1555 
-> 1556         return cls._read_csv_impl(
   1557             url,

~/MLvenv/lib/python3.8/site-packages/turicreate/data_structures/sframe.py in _read_csv_impl(cls, url, delimiter, header, error_bad_lines, comment_char, escape_char, double_quote, quote_char, skip_initial_space, column_type_hints, na_values, line_terminator, usecols, nrows, skiprows, verbose, store_errors, nrows_to_infer, true_values, false_values, _only_raw_string_substitutions, **kwargs)
    985                 # Get the first nrows_to_infer rows (using all the desired arguments).
--> 986                 first_rows = SFrame.read_csv(
    987                     url,

~/MLvenv/lib/python3.8/site-packages/turicreate/data_structures/sframe.py in read_csv(cls, url, delimiter, header, error_bad_lines, comment_char, escape_char, double_quote, quote_char, skip_initial_space, column_type_hints, na_values, line_terminator, usecols, nrows, skiprows, verbose, nrows_to_infer, true_values, false_values, _only_raw_string_substitutions, **kwargs)
   1555 
-> 1556         return cls._read_csv_impl(
   1557             url,

~/MLvenv/lib/python3.8/site-packages/turicreate/data_structures/sframe.py in _read_csv_impl(cls, url, delimiter, header, error_bad_lines, comment_char, escape_char, double_quote, quote_char, skip_initial_space, column_type_hints, na_values, line_terminator, usecols, nrows, skiprows, verbose, store_errors, nrows_to_infer, true_values, false_values, _only_raw_string_substitutions, **kwargs)
   1093             with cython_context():
-> 1094                 errors = proxy.load_from_csvs(internal_url, parsing_config, type_hints)
   1095         except Exception as e:

~/MLvenv/lib/python3.8/site-packages/turicreate/_cython/context.py in __exit__(self, exc_type, exc_value, traceback)
     49                 # To hide cython trace, we re-raise from here
---> 50                 raise exc_type(exc_value)
     51             else:

OSError: Cannot open /home/anagene/people-example.csv for read. Cannot open /home/anagene/people-example.csv for reading

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<ipython-input-8-d54163f18f67> in <module>
----> 1 sf = turicreate.SFrame(r'people-example.csv')

~/MLvenv/lib/python3.8/site-packages/turicreate/data_structures/sframe.py in __init__(self, data, format, _proxy)
    836                     pass
    837                 else:
--> 838                     raise ValueError("Unknown input type: " + format)
    839 
    840     @staticmethod

~/MLvenv/lib/python3.8/site-packages/turicreate/_cython/context.py in __exit__(self, exc_type, exc_value, traceback)
     48             if not self.show_cython_trace:
     49                 # To hide cython trace, we re-raise from here
---> 50                 raise exc_type(exc_value)
     51             else:
     52                 # To show the full trace, we do nothing and let exception propagate

OSError: Cannot open /home/anagene/people-example.csv for read. Cannot open /home/anagene/people-example.csv for reading

【问题讨论】:

    标签: python jupyter-notebook turi-create


    【解决方案1】:

    遇到了完全相同的问题,通过在 ubuntu 上执行以下代码向所有人授予文件访问权限来解决: sudo chmod a+rwx /home/anagene/people-example.csv 其中后半部分是文件路径。

    将文件名 a/c 更改为您的查询,以便您可以直接使用上述代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-10
      • 2021-02-16
      • 1970-01-01
      • 2014-06-27
      • 2013-05-06
      • 1970-01-01
      • 2011-11-19
      相关资源
      最近更新 更多