I wrote a program that will copy a file called a.exe to C:/Windows/, then I pack it to exe with PyInstaller, and rename the exe file to a.exe. When I run the exe file, it output IOError [Errno 13] Permisson denied: 'C:/Windows/a.exe', but the file a.exe was copied to the directory C:/Windows. Then I ran it as the Administrator, it happened again...
At first, I copy the file with shututil.copy, then I wrote a function myself(open a.exe, create a.exe under C:/Windows, read a.exe 's content and write to C:/Windows/a.exe, close all), but it doesn't help...Any ideas?
Check if a.exe has read-only attribute. shutil.copy raises "Permission denied" error when it is called to overwrite existing file with read-only attribute set
Apparently you're trying to execute a file that moves itself to a different place ... I guess that cannot work.
Can you copy files that are open in Windows? I have a vague memory that you can't, and the file will be open while you execute it.
Is it really being copied? It doesn't exist there before copying? Did it copy the whole file?
Related
I am trying to save the output dataframe to a csv file while using pyinstaller to create an exe, but my code freezes and generate "[Errno 13] Permission denied: '.\Output.csv' " error. My question is. what wrong using df.to_csv to save the output file in the same exe directory ?
Thanks in adcance
Look, if you use Innodb compiler then you will face a problem of permission denied error in the setup. So , I have tried to solve that by using temporary file but It is getting deleted after generation. But if you really want to solve this problem then use xlsxwriter and save it to a specific file location.
I am using the python-docx library to make docx files and then later print them to PDF's. Normally, i use os.remove(file_path)
to get rid of the docx files created during the process. If I do not destroy these files and then run the script again, I get an error because the file is locked for editing. I'm trying to understand what is happening here and what the proper protocol is for dealing with these intermediate files.
Any help would be appreciated.
The script generates a docx file called Example.docx and then converts the docx file to a pdf. If I destroy the docx file, I can run the script again with no problem. If I do not destroy Example.docx, I get this error: PermissionError: [Errno 13] Permission denied: 'Example.docx'
I'm trying to understand why this is occurring.
I've tried reading through the other answered similar questions, yet still can't find what I'm doing wrong.
file=open("Crawl","r")
cont=file.read()
file.close
print(cont)
It's as simple as that. Both the folder and python are on the desktop which explains why there isn't a directory to it. I did try opening .txt and .png files and that did work, but it seems I can't open folders?
PermissionError: [Errno 13] Permission denied: 'Crawl'
You are getting this error because you are trying to open "Crawl" as a file. It's a folder, and you can't treat a Windows folder as if it were a file.
Disclaimer This question might be a duplicate of a question I could not find by searching.
I am trying to open a .txt file I downloaded. I used:
with open("spam.txt", "a+") as ef:
#other code that works
and I am gettingIOError [Errno 13] Permission denied: 'spam.txt'
Is there something I did wrong or do I have to open the file a different way?
Edit: I checked and I do have all the read, write, and execute permissions for the file and I can open it on Notepad. I am using Windows as my OS.
Well, I got the problem fixed. It turned out that Komodo Edit 9.3 needs to be in Admin Mode in order to do anything with files now.
The way to get past it is to run Komodo Edit as Admin or run it from a Python window.
I do not believe it is your code. Are you on a linux environment? If so, check to see if the file has read permissions.
The code works just fine.
with open("white-list.txt","a+") as ef:
print ef
<open file 'white-list.txt', mode 'a+' at 0x10206a6f0>
https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
I have the following simple code:
fh = open('example.txt','w')
fh.write('something')
fh.close()
If I use Python's IDLE, the scripts works as intended, it creates a file called example.txt in the same directory that the script is in.
But, if I do the same from within Notepad++, using the "Run..." command and the command line c:\python35\python.exe -i "$(FULL_CURRENT_PATH)", it opens the python window, opens the script file and gives a PermissionError: [Errno 13] Permission denied: 'example.txt'
I don't know what this thing is doing, I suspect that its trying to write the example.txt file inside the python's directory and not where the script is. So, I changed the command line in the Run command in Notepad++ to simply python -i "$(FULL_CURRENT_PATH)" (I have the python directory in the %PATH%), but it gives the same error.
I know this problem is more related to Notepad++ configuration than to a python problem, but any help will be appreciated.
I'm using Windows 10, python 3.5, Notepad++ 6.8.1
Thanks a lot.
The correct answer is what Juxhin said, Notepad++ must be run as administrator. I liked it was posted as an answer!!!