簡體   English   中英

PermissionError: [WinError 5] 權限被拒絕

[英]PermissionError: [WinError 5] Permission denied

我有 PermissionError 的問題:[WinError 5] 權限被拒絕。 有人可以告訴我為什么嗎?

import subprocess

run_shell = subprocess.run(['./', 'ls'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

test = str(run_shell.stdout.decode()).split('\n')

for el in test:
    if not el:
        continue
    print(f"Plik: {el}")
print("Info: {}".format(run_shell.stderr.decode()))

即使我只嘗試使用子流程,我仍然擁有它。

import subprocess
subprocess.run(['./', 'ls'])

試過這個,沒有幫助。

subprocess.run([r'./', 'ls']) 

錯誤:

Traceback (most recent call last):
  File "c:\Users\gawiq\KodyPython\lekcja_5_8.py", line 4, in <module>
    run_shell = subprocess.run(['./', 'ls'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Users\gawiq\AppData\Roaming\Python\Python310\lib\subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\gawiq\AppData\Roaming\Python\Python310\lib\subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\gawiq\AppData\Roaming\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Permission denied
PS C:\Users\gawiq\KodyPython>

我已經在具有管理員權限的 CLI 中嘗試過: pip install pydirectory, python -m pip install --upgrade Z62AD1C2A463CFEBA2888

我也試過

pip install --user subprocess.run,

但后來,我得到了這個:

Python: 'list' object has no attribute 'read'

Python 版本 3.10.5 pip 版本 22.2.1 使用 Windows 10 家庭 64 位和 VSC

感謝幫助

您的問題可能是ls./都不是 Windows CLI 的有效命令

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM