PermissionError: [Errno 13] Permission denied: 'C:\Users\airline1\sample.csv'

这是我的代码,我尝试了所有的东西,但无法解决,请大家帮忙

import matplotlib.pyplot as plt
import pandas as pd
import pylab as pl
import numpy as np
%matplotlib inline
ds=pd.read_csv(r"C:\Users\airline1\sample.csv",engine="python")

输出。

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
<ipython-input-13-386663eb1d85> in <module>
----> 1 ds=pd.read_csv(r"C:\Users\airline1\sample.csv",engine="python")

c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
    674         )
    675 
--> 676         return _read(filepath_or_buffer, kwds)
    677 
    678     parser_f.__name__ = name

c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
    446 
    447     # Create the parser.
--> 448     parser = TextFileReader(fp_or_buf, **kwds)
    449 
    450     if chunksize or iterator:

c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds)
    878             self.options["has_index_names"] = kwds["has_index_names"]
    879 
--> 880         self._make_engine(self.engine)
    881 
    882     def close(self):

c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine)
   1124                     '"python-fwf")'
   1125                 )
-> 1126             self._engine = klass(self.f, **self.options)
   1127 
   1128     def _failover_to_python(self):

c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pandas\io\parsers.py in __init__(self, f, **kwds)
   2262         self._comment_lines = []
   2263 
-> 2264         f, handles = get_handle(
   2265             f,
   2266             "r",

c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pandas\io\common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text)
    429         elif is_text:
    430             # No explicit encoding
--> 431             f = open(path_or_buf, mode, errors="replace", newline="")
    432         else:
    433             # Binary mode

PermissionError: [Errno 13] Permission denied: 'C:\\Users\\airline1\\sample.csv'

解决方案:

你根本没有权限读取那个文件(或者它可能是一个目录)。

看起来你的用户是 hp (基于 c:\users\hp),而数据文件可能是由一个叫做 airline1 (基于 c:\users\airline1).

你要问 airline1 授予您读取文件的权限。

给TA打赏
共{{data.count}}人
人已打赏
解决方案

当加载Moodle网站时,是什么原因导致默认的Apache页面打开?

2022-5-14 4:00:19

解决方案

如何使用powershell安装Opera网页浏览器系统级(对所有用户而言。

2022-5-14 5:00:11

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索