简体   繁体   中英

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

on a local copy of 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). But the important bit is that this code is written for Python 2 and isn't compatible with the 3 you're using. (Other parts use print statements and wouldn't even compile.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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