gpt4 book ai didi

python - IO错误: [Errno 13] Permission denied Pandas

转载 作者:太空宇宙 更新时间:2023-11-03 20:37:35 25 4
gpt4 key购买 nike

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

pandas.errors.ParserError: Error tokenizing data. C error: Calling read(nbytes) on source failed. Try 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] Permission denied

之前对其他线程的回答都没有帮助,知道吗?谢谢。

回溯:

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```

最佳答案

您的程序存在权限问题。你可以尝试一下

sudo chmod o+r <address>

它指向的文件在哪里。

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

然后运行命令

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

关于python - IO错误: [Errno 13] Permission denied Pandas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57069686/

25 4 0
文章推荐: opencv - 为什么安装 opencv 后 cv2.so 不见了?
文章推荐: c# - 当我想要一个集合时,dbml 从我的存储过程中生成 ISingleResult