Python PermissionError:[Errno 13]在加载带有熊猫的文件时出现权限被拒绝错误
我得到了这个错误:Python PermissionError:[Errno 13]在加载带有熊猫的文件时出现权限被拒绝错误,python,pandas,watchdog,python-watchdog,Python,Pandas,Watchdog,Python Watchdog,我得到了这个错误: Exception in thread Thread-1: Traceback (most recent call last): File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner self.run() File "C:\Users\40005139\Ap
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\watchdog\observers\api.py", line 199, in run
self.dispatch_events(self.event_queue, self.timeout)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\watchdog\observers\api.py", line 372, in dispatch_events
handler.dispatch(event)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\watchdog\events.py", line 403, in dispatch
super().dispatch(event)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\watchdog\events.py", line 278, in dispatch
}[event.event_type](event)
File "d:/Railway_Scenario/DataUpload.py", line 16, in on_created
pd.read_csv(file)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 610, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 462, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 819, in __init__
self._engine = self._make_engine(self.engine)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 1050, in _make_engine
return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 1867, in __init__
self._open_handles(src, kwds)
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 1368, in _open_handles
storage_options=kwds.get("storage_options", None),
File "C:\Users\40005139\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\common.py", line 647, in get_handle
newline="",
PermissionError: [Errno 13] Permission denied: 'D:\\Railway_Scenario\\ProfileData.csv'
运行此操作时:
class Handler(watchdog.events.PatternMatchingEventHandler):
def __init__(self):
# Set the patterns for PatternMatchingEventHandler
watchdog.events.PatternMatchingEventHandler.__init__(self, patterns=['*.xls'],
ignore_directories=True, case_sensitive=False)
def on_created(self, event):
print("Watchdog received created event - % s." % event.src_path)
df=pd.read_excel(event.src_path)
有人能告诉我在创建事件时我是如何读取文件的,或者片段中有什么错误吗
规格:Python 3.7.6 x86 Windows 10 x64
谢谢更改
ProfileData.csv
文件的权限,以便用户可以读取该文件。已授予读写权限,但仍会得到相同的错误计算机不会说谎。如果已授予权限,则不会出现错误。是否确定脚本正在以具有权限的用户身份运行?请在D:\Railway\u场景中检查文件夹权限