[GH-ISSUE #268] Permission Denied When Exporting Files #239

Closed
opened 2026-02-26 12:20:55 +03:00 by kerem · 12 comments
Owner

Originally created by @ghost on GitHub (May 2, 2022).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/268

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()
Originally created by @ghost on GitHub (May 2, 2022). Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/268 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()
kerem 2026-02-26 12:20:55 +03:00
  • closed this issue
  • added the
    Stale
    label
Author
Owner

@brentvollebregt commented on GitHub (May 3, 2022):

Can you please provide the whole exception and stack trace

<!-- gh-comment-id:1115868728 --> @brentvollebregt commented on GitHub (May 3, 2022): Can you please provide the whole exception and stack trace
Author
Owner

@Abhijeetbyte commented on GitHub (May 3, 2022):

@DINOTICK-Dev , You can try this method

<!-- gh-comment-id:1116004643 --> @Abhijeetbyte commented on GitHub (May 3, 2022): @DINOTICK-Dev , You can try this [ method](https://github.com/Abhijeetbyte/Python-Script-to-Application.git)
Author
Owner

@ghost commented on GitHub (May 4, 2022):

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

<!-- gh-comment-id:1117259995 --> @ghost commented on GitHub (May 4, 2022): It compiles fine, but I get an error saying permission denied after selecting an image to export into a gif file.
Author
Owner

@ghost commented on GitHub (May 4, 2022):

@DINOTICK-Dev , You can try this method

wdym by that?

<!-- gh-comment-id:1117262830 --> @ghost commented on GitHub (May 4, 2022): > @DINOTICK-Dev , You can try this [ method](https://github.com/Abhijeetbyte/Python-Script-to-Application.git) wdym by that?
Author
Owner

@Abhijeetbyte commented on GitHub (May 5, 2022):

@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.

<!-- gh-comment-id:1118552642 --> @Abhijeetbyte commented on GitHub (May 5, 2022): > > @DINOTICK-Dev , You can try this [ method](https://github.com/Abhijeetbyte/Python-Script-to-Application.git) > > 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.
Author
Owner

@ghost commented on GitHub (May 5, 2022):

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)

<!-- gh-comment-id:1118769841 --> @ghost commented on GitHub (May 5, 2022): 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)
Author
Owner

@Abhijeetbyte commented on GitHub (May 7, 2022):

@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
<!-- gh-comment-id:1120255162 --> @Abhijeetbyte commented on GitHub (May 7, 2022): @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
Author
Owner

@ghost commented on GitHub (May 9, 2022):

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

<!-- gh-comment-id:1120987812 --> @ghost commented on GitHub (May 9, 2022): @Abhijeetbyte I have already tried that. I also tried building with just PyInstaller, with administrator, and set the directory to my downloads.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 19, 2022):

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.

<!-- gh-comment-id:1159594069 --> @github-actions[bot] commented on GitHub (Jun 19, 2022): 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.
Author
Owner

@github-actions[bot] commented on GitHub (Jul 21, 2022):

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.

<!-- gh-comment-id:1190932492 --> @github-actions[bot] commented on GitHub (Jul 21, 2022): 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.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 22, 2022):

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.

<!-- gh-comment-id:1221692380 --> @github-actions[bot] commented on GitHub (Aug 22, 2022): 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.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 27, 2022):

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

<!-- gh-comment-id:1229094557 --> @github-actions[bot] commented on GitHub (Aug 27, 2022): Closing issue due to no activity in more than 60 days.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/auto-py-to-exe#239
No description provided.