I am creating an application in python (3.4) with tkinter and I am compiling it with pyinstaller. The code fragment that brings the error is this:
client = paramiko.SSHClient()
known_hosts = open(self.resource_path("known_hosts")) # Linea 73
client.load_host_keys(known_hosts)
The error is thrown when I click on a button that executes that part of the code, that is, the application runs rather well. The error is this:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1538, in __call__
File "prueba.py", line 73, in aceptar
PermissionError: [Errno 13] Permission denied: 'C:\Users\Hernan\AppData\Local\Temp\_MEI124282\known_hosts'
I clarify that I am compiling it and running on windows 10.
I tried to run the exe as an administrator but it still gives the same error. I checked the path of the file and it exists, so I discard that the file does not exist. I also tried to compile the exe in a cmd with administrator's permission, but it did not give me a solution either.
Any ideas?
PS: add code ...
def resource_path(self, relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)