简体   繁体   English

Python-PermissionError:[WinError 5]访问被拒绝:

[英]Python - PermissionError: [WinError 5] Access is denied:

I am trying to run this script: https://github.com/Lab41/hermes/blob/master/src/utils/code_etl/repo_to_json.py 我正在尝试运行此脚本: https : //github.com/Lab41/hermes/blob/master/src/utils/code_etl/repo_to_json.py

on a local copy of matplotlib. 在matplotlib的本地副本上。 But I keep receiving this error message that I don't understand. 但是我一直收到我不理解的错误消息。 I've trying running it in command prompt in administrator mode but still get the error. 我尝试在管理员模式下的命令提示符下运行它,但仍然收到错误。

 Traceback (most recent call last):
  File "C:/Users/daman/Desktop/hermes-master/src/utils/code_etl    /repo_to_json.py", line 211, in <module>
repo_name
  File "C:/Users/daman/Desktop/hermes-master/src/utils/code_etl/repo_to_json.py", line 130, in process_local_repo
output_file = output_dir + "/" + repo_name.replace('/', '_') + ".json"
TypeError: a bytes-like object is required, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/daman/Desktop/hermes-master/src/utils/code_etl/repo_to_json.py", line 211, in <module>
repo_name
  File "C:\Users\daman\Desktop\hermes-master\src\utils\code_etl\git_manager.py", line 66, in __exit__
shutil.rmtree(self.__tempdir)
  File "C:\Users\daman\AppData\Local\Programs\Python\Python37-32\lib\shutil.py", line 507, in rmtree
return _rmtree_unsafe(path, onerror)
  File "C:\Users\daman\AppData\Local\Programs\Python\Python37-32\lib\shutil.py", line 386, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
  File "C:\Users\daman\AppData\Local\Programs\Python\Python37-32\lib\shutil.py", line 386, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
  File "C:\Users\daman\AppData\Local\Programs\Python\Python37-32\lib\shutil.py", line 386, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
  File "C:\Users\daman\AppData\Local\Programs\Python\Python37-32\lib\shutil.py", line 391, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\daman\AppData\Local\Programs\Python\Python37-32\lib\shutil.py", line 389, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\daman\\AppData\\Local\\Temp\\tmpe6tqnsio\\matplotlib\\.git\\objects\\pack\\pack-e0ef0cedb6b5eee531ff1c53aea599034caa1649.idx'

The failure to clean up the temporary repository may be due to some other part of the code still having the Git object file in question open (which, on Windows, prevents deletion). 无法清除临时存储库可能是由于代码的其他部分仍打开了有问题的Git对象文件(在Windows上,这可以防止删除)。 But the important bit is that this code is written for Python 2 and isn't compatible with the 3 you're using. 但是重要的一点是该代码是为Python 2编写的,并且与您使用的3不兼容。 (Other parts use print statements and wouldn't even compile.) (其他部分使用print语句,甚至不会编译。)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM