PermissionError: [Errno 13] Permission denied: 'C:\\Users\\12247\\AppData\\Local\\Temp\\tmpszvn299g\\tmph0n1bgkz.py'
时间: 2023-08-15 15:07:23 浏览: 153
引用[1]:修改后出现PermissionError: [Errno 13] Permission denied: 'C:\Users\Computer\AppData\Local\Temp\tmph7wo8mp3’权限错误 如图: Linux安装 环境 。 引用[2]:2、 PermissionError: [Errno 13] Permission denied: ‘C:\Users\ADMINI~1\AppData\Local\Temp\tmph33fyd1n’ 这个可能和操作系统权限机制有关系,在window 7 下会报这个错,对临时文件,用open打开时就会报这个错。 为了能运行,我就简单修改了下代码:在bleu.py : 72 行, 改为如下,随便读取一个文件, with open(“D:\work\XXXX\documents\test.txt”, “r”) as read_pred: 在79行 把read_pred 改为hypothesis_file 临时文件 bleu_out = subprocess.check_output( bleu_cmd, stdin=hypothesis_file, stderr=subprocess.STDOUT) 。 引用[3]:AttributeError: module ‘tensorflow.python.platform.flags’ has no attribute ‘_FlagValues’ 解决方式:修改 seq2seq/test/pipeline_test.py 文件: 问题四 。 问题:PermissionError: [Errno 13] Permission denied: 'C:\\Users\\12247\\AppData\\Local\\Temp\\tmpszvn299g\\tmph0n1bgkz.py'
回答: 这个错误是由于操作系统权限机制导致的。在Windows 7下,当尝试打开临时文件时,会报PermissionError: [Errno 13] Permission denied错误。为了解决这个问题,可以进行以下修改:在bleu.py的第72行,将打开文件的路径改为一个随意的文件路径,例如with open("D:\work\XXXX\documents\test.txt", "r") as read_pred:。然后在第79行,将read_pred改为hypothesis_file,即bleu_out = subprocess.check_output(bleu_cmd, stdin=hypothesis_file, stderr=subprocess.STDOUT)。这样就可以避免权限错误的问题。另外,对于AttributeError: module 'tensorflow.python.platform.flags' has no attribute '_FlagValues'错误,可以通过修改seq2seq/test/pipeline_test.py文件来解决。