auto-py-to-exe icon indicating copy to clipboard operation
auto-py-to-exe copied to clipboard

Permission Denied When Exporting Files

Open DINOTICK-Dev opened this issue 2 years ago • 10 comments

I am making a very dumb and stupid application, and I decided to turn it into a .exe file. It exports completely fine and runs fine up until one point. For some background, I am making an application that takes an image and turns it into a pet the X or a pet pet. Everything works fine up to the point where it's turned into a .exe and I run it as a .exe. Everything works fine and then I export the petpet file and it says that permission is denied. Any fixes? I am running on Windows 10, and the code works absolutely fine when it's just in python and not an executable. I do not believe it's my code that's the problem more like how PyInstaller and auto-py-to-exe works. I hope I can get this working soon as I have a pretty big project that uses file system stuff too that would be ruined if I couldn't turn it into an exe. Here's my code. The modules that are being used are tkinter, os, pathlib, and I was going to remove sv_ttk. Oh and don't forget the beautiful petpet module. I am using the latest version of python. filedirectory is the file to convert. btw downloaddir is replaced with a file dialog with tkinter but I don't have access to that code right now. There's still no reason why it shouldn't work to begin with though.

from petpetgif import petpet  
from tkinter import filedialog, simpledialog, messagebox
from tkinter import *
import os
from pathlib import Path
import sv_ttk

root = Tk()
root.withdraw()
sv_ttk.set_theme("light")

fileDirectory = filedialog.askopenfilename(title="Select image to pet", filetypes=[("PNG Files", "*.png"), ("JPG Files", "*.jpg")])
if (len(fileDirectory) == 0):
  messagebox.showerror(title="Error", message="You didn't select a file.")
  quit()
outputName = simpledialog.askstring("Output File Name", "What would you like the output file name to be?")
download_dir = str(Path.home() / "Downloads")


if os.name == "posix": #If linux/mac/bsd...
  setDirectory = filedialog.askdirectory(title = "Output for petpet")
  try:
    petpet.make(fileDirectory, setDirectory+"/"+outputName+".gif")
    messagebox.showinfo(title="Petpet Success!", message=f"Success! Your pet-pet can be found at {setDirectory}!")
  except:
    messagebox.showerror(title="Error", message="Error: There was an issue exporting your pet-pet! :( Do you have permissions/root?")
    quit()
else: #If Windows...
  try:
    petpet.make(fileDirectory, download_dir+"/"+outputName+".gif") # file directory is the file to convert
    messagebox.showinfo(title="Petpet Success!", message=f"Success! Your pet-pet can be found at {download_dir}!")
  except:
    messagebox.showerror(title="Error", message="Error: There was an issue exporting your pet-pet! :( Do you have permissions/root?")
    quit()

quit()

DINOTICK-Dev avatar May 02 '22 12:05 DINOTICK-Dev

Can you please provide the whole exception and stack trace

brentvollebregt avatar May 03 '22 08:05 brentvollebregt

@DINOTICK-Dev , You can try this method

Abhijeetbyte avatar May 03 '22 11:05 Abhijeetbyte

It compiles fine, but I get an error saying permission denied after selecting an image to export into a gif file.

ghost avatar May 04 '22 12:05 ghost

@DINOTICK-Dev , You can try this method

wdym by that?

ghost avatar May 04 '22 12:05 ghost

@DINOTICK-Dev , You can try this method

wdym by that?

You should try Pyinstaller manually, going through all individual commands. Cause u said

I do not believe it's my code that's the problem more like how PyInstaller and auto-py-to-exe works.

Abhijeetbyte avatar May 05 '22 13:05 Abhijeetbyte

Oh ok then. I'll see if that works... Which I honestly doubt that it will. I'll keep you informed if it does and possibly a PR if I find why this is happening and I manage to fix it. (I love pull requests lol)

ghost avatar May 05 '22 16:05 ghost

@DINOTICK-Dev May be it's an Admin permission problem

Everything works fine and then I export the petpet file and it says that permission is denied. Any fixes? I am running on Windows 10, and the code works absolutely fine when it's just in python and not an executable.

  • Try to run your exe with Administrator permission Run as administrator. If does work then try --uac-admin command with pyinstaller

Abhijeetbyte avatar May 07 '22 18:05 Abhijeetbyte

@Abhijeetbyte I have already tried that. I also tried building with just PyInstaller, with administrator, and set the directory to my downloads.

ghost avatar May 09 '22 11:05 ghost

This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.

github-actions[bot] avatar Jun 19 '22 01:06 github-actions[bot]

This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.

github-actions[bot] avatar Jul 21 '22 01:07 github-actions[bot]

This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.

github-actions[bot] avatar Aug 22 '22 01:08 github-actions[bot]

Closing issue due to no activity in more than 60 days.

github-actions[bot] avatar Aug 27 '22 01:08 github-actions[bot]