PermissionError: [WinError 5] Access is denied when code is Executed - python

I was building a Rich Presence application and it worked totally fine until today. When I ran the code today it no longer worked and I get a error, mind you I didn't change a single bit of code. Does anyone know what could the problem be? I have attached the error. Also I ran the code as admin and it worked but it doesn't show the Rich Presence.
Error:
Traceback (most recent call last):
File "c:\Users\MyName\Desktop\DiscoRP v2\main.py", line 11, in <module>
from applet import quotegen
File "c:\Users\MyName\Desktop\DiscoRP v2\applet\quotegen.py", line 11, in <module>
connectionManager.connection(RPC)
File "c:\Users\MyName\Desktop\DiscoRP v2\config\connectionManager.py", line 5, in connection
RPC.connect()
File "C:\Users\MyName\AppData\Local\Programs\Python\Python39\lib\site-packages\pypresence\presence.py", line 43, in connect
self.loop.run_until_complete(self.handshake())
File "C:\Users\MyName\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "C:\Users\MyName\AppData\Local\Programs\Python\Python39\lib\site-packages\pypresence\baseclient.py", line 134, in handshake
self.sock_writer, _ = await self.loop.create_pipe_connection(lambda: reader_protocol, self.ipc_path)
File "C:\Users\MyName\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 333, in create_pipe_connection
pipe = await f
File "C:\Users\MyName\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 652, in connect_pipe
handle = _overlapped.ConnectPipe(address)
PermissionError: [WinError 5] Access is denied
What Am I supposed to do?

Because can't see your code, maybe you can check this PermissionError: [WinError 5] Access is denied
Someone's solution looks like to modify the path of the file.

Related

python readline module giving PermissionError: [Errno 1] only when run at startup

I'm making a console based game that saves input history, to help with debugging I created a function that will automatically input commands on start
def __readfile (self) -> None:
lines = None
with open("insts.txt", "r") as f:
lines = f.read().split("\n")
if (lines == None):
print("attempted to read insts.txt for instructions, could not find file")
return
self.__initfile = True
for line in lines:
self.parse_input(line)
self.__initfile = False
in the instance of the error "self.parse_input" ultimately leads to "readline.read_history_file" and none of the code in between the two has any effect on the error
but it gives this error message:
Traceback (most recent call last):
File "main.py", line 9, in <module>
game.start()
File "/Users/tristans/Documents/GitHub/console-rpg/classes.py", line 1353, in start
self.__readfile()
File "/Users/tristans/Documents/GitHub/console-rpg/classes.py", line 1345, in __readfile
self.parse_input(line)
File "/Users/tristans/Documents/GitHub/console-rpg/classes.py", line 1223, in parse_input
self._parse_dialog(text)
File "/Users/tristans/Documents/GitHub/console-rpg/classes.py", line 1128, in _parse_dialog
self._parse_dialog("leave")
File "/Users/tristans/Documents/GitHub/console-rpg/classes.py", line 1101, in _parse_dialog
self._load_hist_scope()
File "/Users/tristans/Documents/GitHub/console-rpg/classes.py", line 1331, in _load_hist_scope
readline.read_history_file("history.txt")
PermissionError: [Errno 1] Operation not permitted
I have looked everywhere for an answer to where this error is coming from and can't find one
I've tried changing the file read operation from the "with open("insts.txt")" to a hardcoded list but that didn't work, os.access("history.txt", os.R_OK) also returns true when called just before "readline.read_history_file"
It appears to be a Mac-specific issue with readline. According to this answer, you need to use gnureadline on the Mac, rather than readline.
import gnureadline as readline

Getting intermittent write error while extracting files from zip archive

I have a small application that I have made. It basically copies a zip file from a network location to the computer that is running the application, unzips it in a folder and then creates a shortcut on the desktop.
Most of the time (I'd say about 80%) it works as intended. The other 20% of the time the stack trace it says it cannot create a file. It is always the same (_bz2.pyd). If I close it and run it again it works fine after this happens.
Anyone have any ideas of what is going on? Here is the code that extracts the file. I've even made the script try and extract the file, check if it worked, try and extract the file again. This hasn't solved the issue:
print ('uncompressing databases. This takes a few minutes')
# file_name = settings.working_folder + r'\UAT_Databases.zip'
temp_name = settings_dict['working_folder'] + settings_dict['file_name']
zip_ref = zipfile.ZipFile(temp_name, 'r')
zip_ref.extractall(settings_dict['install_folder'])
zip_ref.close()
logr.info('unzipped databases')
Here is the stack trace:
Traceback (most recent call last):
File "temp_installer.py", line 141, in unzip_databases
File "zipfile.py", line 1347, in extractall
File "zipfile.py", line 1335, in extract
File "zipfile.py", line 1398, in _extract_member
PermissionError: [Errno 13] Permission denied: 'C:\\TempApps\\Temp_application\\_bz2.pyd'
2020-03-03 11:36:25,697 : ERROR : __main__ : could not unzip databases
Traceback (most recent call last):
File "temp_installer.py", line 141, in unzip_databases
File "zipfile.py", line 1347, in extractall
File "zipfile.py", line 1335, in extract
File "zipfile.py", line 1398, in _extract_member
PermissionError: [Errno 13] Permission denied: 'C:\\TempApps\\Temp_application\\_bz2.pyd'

DASK : IOError: [Errno 13] Permission denied:

I am using Dask 0.10 with the latest Anaconda distribution and I run into the following error after calling .compute(get=dask.multiprocessing.get) :
File "<ipython-input-8-cd6a1c9a02b6>", line 309, in find_matches
merged = data.merge(matches, on='url', how='left')
File "C:\Users\user\AppData\Local\Continuum\Anaconda2\lib\site-packages\dask\dataframe\core.py", line 1664, in merge
suffixes=suffixes, npartitions=npartitions)
File "C:\Users\user\AppData\Local\Continuum\Anaconda2\lib\site-packages\dask\dataframe\multi.py", line 428, in merge
how, npartitions, suffixes)
File "C:\Users\user\AppData\Local\Continuum\Anaconda2\lib\site-packages\dask\dataframe\multi.py", line 257, in hash_join
lhs2 = shuffle(lhs, left_on, npartitions)
File "C:\Users\user\AppData\Local\Continuum\Anaconda2\lib\site-packages\dask\dataframe\shuffle.py", line 160, in shuffle
import partd
File "C:\Users\user\AppData\Local\Continuum\Anaconda2\lib\site-packages\partd\__init__.py", line 16, in <module>
from .zmq import Client, Server
File "C:\Users\user\AppData\Local\Continuum\Anaconda2\lib\site-packages\partd\zmq.py", line 33, in <module>
log('Import zmq')
File "C:\Users\user\AppData\Local\Continuum\Anaconda2\lib\site-packages\partd\zmq.py", line 29, in log
with open('log', 'a') as f:
IOError: [Errno 13] Permission denied: 'log'
I have no idea what is causing this. Does Dask needs to write on the root directory? I am working on a machine where I dont have admin rights and where there is a firewall.
Does Dask needs to write on the root directory?
No, Dask operates entirely within userspace, as does Anaconda generally. In the traceback provided it looks like the error is coming from trying to open a file named "log" in the local directory. Perhaps you're running Dask from a place where you don't have write permission?

scapy bad file descriptor

scapy OSError: [Errno 9] Bad file descriptor
same error as this guy . using python 2.7.5 on windows.downloded all the extentions and followed everything step by step. still doesnt seem to work. every function i try wheter it's sr1 or send or anything else i get this error OSError: [Errno 9] Bad file descriptor..
and it mentiones lines in some of the scapy scripts (scapy\sendrecv.pyc as example..)
the simplest things i try running in the interpreter doesnt work. as in :
from scapy.all import *
p=sr1(IP(dst='190.200.2.5')/ICMP())
so i tried reinstalling this time everything according to the guide they provide int the website and using python 2.6 , same results ..
>>> p=sr1(IP(dst='192.168.1.1')/ICMP())
ERROR: --- Error sending packets
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\scapy\arch\windows\__init__.py", line 374, in sndrcv
pks.send(p)
File "C:\Python26\lib\site-packages\scapy\arch\pcapdnet.py", line 237, in send
ifs = dnet.eth(iff)
File "dnet.pyx", line 112, in dnet.eth.__init__
OSError: Result too large
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
p=sr1(IP(dst='192.168.1.1')/ICMP())
File "C:\Python26\lib\site-packages\scapy\sendrecv.py", line 335, in sr1
a,b=sndrcv(s,x,*args,**kargs)
File "C:\Python26\lib\site-packages\scapy\arch\windows\__init__.py", line 431, in sndrcv
os.write(1, ".")
OSError: [Errno 9] Bad file descriptor

Using numdisplay, "An existing connection was forced to close by the remote host"

I've been learning to use python in astronomy and for that I'm following this notes. In the very beginning the author does the following example:
>>> im = pyfits.getdata('http://das.sdss.org/www/cgi-bin/drC?RUN=3630&RERUN=40&CAMCOL=3&FIELD=83&FILTER=r')
>>> numdisplay.display(im,z1=1000,z2=1500)
I try to replicate it and I get:
>>> numdisplay.display(im,z1=1000,z2=1500)
Image displayed with Z1: 1000 Z2: 1500
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
numdisplay.display(im,z1=1000,z2=1500)
File "C:\Mine\Python\lib\site-packages\numdisplay\__init__.py", line 446, in display
_d.writeImage(bpix,_wcsinfo)
File "C:\Mine\Python\lib\site-packages\numdisplay\displaydev.py", line 513, in writeImage
self.writeData(_lx,_ydisp,_fpix[block,:])
File "C:\Mine\Python\lib\site-packages\numdisplay\displaydev.py", line 379, in writeData
self._writeHeader(opcode,self._MEMORY, -nbytes, x, y, frame, 0)
File "C:\Mine\Python\lib\site-packages\numdisplay\displaydev.py", line 542, in _writeHeader
self._write(a.tostring())
File "C:\Mine\Python\lib\site-packages\numdisplay\displaydev.py", line 580, in _write
nwritten = self._socket.send(s[-n:])
error: [Errno 10054] An existing connection was forced to close by the remote host
I don't understand what I'm doing wrong. I mean if I write numdisplay.open() everything is fine... I'm thinking that it might be my antivirus or something that doesn't let python to communicate with ds9... Can somebody help me?
Edit: Well it doesn't seem to be the antivirus. I stopped it and run the script and I got the same error.
I was getting similar error messages, and I just tried adding a non-'None' argument to the bufname argument and it works (my image is about 4096.4096):
numdisplay.display(data,bufname='imt4096')

Categories

Resources