简体   繁体   English

错误13尝试在不相关的文件夹上写入时权限被拒绝

[英]Error 13 Permission denied when trying to write on unrelated folder

I dont have much experience in python, so it might be a stupid question. 我在python上没有太多经验,所以这可能是一个愚蠢的问题。

Im trying to write to a file in my script, if I run the script from his folder, it works, however if I run it from another folder, I have an error 13 persmission denied 我试图在脚本中写入文件,如果我从他的文件夹中运行脚本,它可以工作,但是,如果我从另一个文件夹中运行,则会出现错误13权限被拒绝

ie in cmd : 即在cmd中:

cd C:\Users\user010\Perforce\Build\LS3\
py Build_jenkins.py

works but 起作用但是

cd C:\Program Files (x86)\Jenkins\workspace\LC3.3 Test\Qt\main
py C:\Users\user010\Perforce\Build\LS3\Build_jenkins.py

doesnt work. 不起作用。 I have tried moving the script and the file to a public folder, same error : 我尝试将脚本和文件移动到公用文件夹,出现相同错误:

Traceback (most recent call last):
  File "C:\Users\Public\Documents\Build\LS3\Build_jenkins.py", line 159, in <module>
    Variables.Sauvegarder()
  File "C:/Users/Public/Documents/Build/LS3/../Common\Variables.py", line 87, in Sauvegarder
    gArbre.write( NOM_FICHIER )
  File "C:\Python34\lib\xml\etree\ElementTree.py", line 761, in write
    with _get_writer(file_or_filename, encoding) as write:
  File "C:\Python34\lib\contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "C:\Python34\lib\xml\etree\ElementTree.py", line 798, in _get_writer
    errors="xmlcharrefreplace")
PermissionError: [Errno 13] Permission denied: 'Variables.xml'

The code is Variables.Sauvegarder() in my main file and in Variables : 代码是我的主文件和Variables中的Variables.Sauvegarder()

import xml.etree.ElementTree as ET
gArbre = ET.parse( "Variables.xml" )
def Sauvegarder():
    gArbre.write( "Variables.xml")

Edit : important detail I forgot to mention, the file im writing to is located in the script folder (C:/Users/Public/Documents/Build/LS3/../Common\\Variables.xml) 编辑:重要的细节我忘了提及,我正在写的文件位于脚本文件夹(C:/ Users / Public / Documents / Build / LS3 /../ Common \\ Variables.xml)

老实说,我不确定Windows计算机(对于使用sudo的mac或其他基于Linux的系统),但是我建议尝试以管理员身份运行命令(使用runas命令以及名称)具有管理员权限的帐户。)这有望解决您遇到的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PermissionError:[Errno 13] 权限被拒绝:尝试将工作簿写入桌面时 - PermissionError: [Errno 13] Permission denied: when trying to write workbook to desktop 尝试加载 Huggingface 数据集时出现 Errno 13 Permission denied 错误 - Errno 13 Permission denied error when trying to load Huggingface dataset 运行 buildozer 时错误 13 权限被拒绝 - Error 13 permission denied when run buildozer 尝试使用Networkx库导出图形时出现Errno 13权限被拒绝的错误 - Errno 13 Permission denied error when trying to export graph with Networkx library 尝试上传图像时出现[Errno 13]权限被拒绝的错误 - I get [Errno 13] Permission denied error when trying to upload images *** ConnectionError:尝试将文件上传到Google Cloud Storage时(“连接已中止。”,错误(13,“权限被拒绝”)) - *** ConnectionError: ('Connection aborted.', error(13, 'Permission denied')) when trying to upload files to Google Cloud Storage Errno13,尝试读取文件时权限被拒绝 - Errno13, Permission denied when trying to read file Python:errno13:尝试复制文件夹时权限被拒绝 - Python: errno13: Permission denied when trying to copy folders Python-尝试复制文件时Errno 13权限被拒绝 - Python - Errno 13 Permission denied when trying to copy files Pickle Error 13 Permission Denied 访问 os 制作的目录时 - Pickle Error 13 Permission Denied when accessing directory made by os
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM