IOError:[Errno 13]权限被拒绝的熊猫

时间:2019-07-17 06:25:48

标签: python pandas

我正在尝试加载数据集,起初我得到一个错误代码:

  

pandas.errors.ParserError:标记数据时出错。 C错误:正在呼叫   在源上读取(nbytes)失败。试试engine ='python'。

然后我添加了engine ='python',因此我的代码如下:

import pandas as pd

pd.set_option('display.max_rows',500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width',1000)
ccr = pd.read_csv('D:/Users/vguevara/ExternalScripts/Colaberry/PythonClass/Consumer_complaints.csv', engine = 'python', sep=',' )
print (ccr)

现在我得到此错误代码:

  

IOError:[Errno 13]权限被拒绝

以前其他线程的答案都没有帮助,有什么想法吗? 谢谢。

跟踪:

Traceback (most recent call last):
  File "D:\Users\vguevara\ExternalScripts\Colaberry\PythonClass\Script14Lab.py", line 8, in <module>
    ccr = pd.read_csv('D:/Users/vguevara/ExternalScripts/Colaberry/PythonClass/Consumer_complaints.csv', engine = 'python', sep=',' )
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 702, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 429, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 895, in __init__
    self._make_engine(self.engine)
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 1132, in _make_engine
    self._engine = klass(self.f, **self.options)
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 2238, in __init__
    self.unnamed_cols) = self._infer_columns()
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 2510, in _infer_columns
    line = self._buffered_line()
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 2689, in _buffered_line
    return self._next_line()
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 2794, in _next_line
    orig_line = self._next_iter_line(row_num=self.pos + 1)
  File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 2854, in _next_iter_line
    return next(self.data)
IOError: [Errno 13] Permission denied```

1 个答案:

答案 0 :(得分:0)

程序中存在权限问题。 您可以尝试

sudo chmod o+r <address>

文件指向的位置。

例如,如果您的错误是 IOError:[Errno 13]权限被拒绝:“ / usr / local / lib / abc / xyz.txt”

然后运行命令

sudo chmod o+r /usr/local/lib/abc/xyz.txt