This is the error: Permission Error: Copying of text from this document is not allowed.
I am opening a .exe file on windows. So regular try except block does not seem to catch it. Neither does OSError.
I solved it with the following:
try:
"""code here"""
except subprocess.CalledProcessError:
"""unlock files and try again"""