[英]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.