DASK : IOError: [Errno 13] Permission denied: - python

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?

Related

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

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.

python giving error in extracting a file from the file

Python code:
import tarfile,os
import sys
def extract_system_report (tar_file_path):
extract_path = ""
tar = tarfile.open(sys.argv[1])
for member in tar.getmembers():
print ("member_name is: ")
print (member.name)
tar.extract(member.name, "./crachinfo/")
extract_system_report(sys.argv[1])
while extracting the file getting below error:
>> python tar_read.py /nobackup/deepakhe/POLARIS_POJECT_09102019/hackathon_2021/a.tar.gz
member_name is:
/bootflash/.prst_sync/reload_info
Traceback (most recent call last):
File "tar_read.py", line 38, in <module>
extract_system_report(sys.argv[1])
File "tar_read.py", line 10, in extract_system_report
tar.extract(member.name, "./crachinfo/")
File "/auto/pysw/cel8x/python64/3.6.10/lib/python3.6/tarfile.py", line 2052, in extract
numeric_owner=numeric_owner)
File "/auto/pysw/cel8x/python64/3.6.10/lib/python3.6/tarfile.py", line 2114, in _extract_member
os.makedirs(upperdirs)
File "/auto/pysw/cel8x/python64/3.6.10/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/auto/pysw/cel8x/python64/3.6.10/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/bootflash'
I am specifying the folder to extract but still it seems trying to create a folder in the root directory. is this behavior expected? I can extract this tar file fine in file manager. is there a way to handle this in python?
I am specifying the folder to extract but still it seems trying to create a folder in the root directory. is this behavior expected?
Yes. The path provided is just a "current directory", it's not a "jail". The documentation even specifically warns about it:
It is possible that files are created outside of path, e.g. members that have absolute filenames starting with "/" or filenames with two dots "..".
I can extract this tar file fine in file manager. is there a way to handle this in python?
Use extractfile to get a pseudo-file handle on the contents of the archived file, then copy that wherever you want.

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'

Permission denied when trying to copy files

Using the script:
file = os.path.join(subfolder_name, list_of_files[i])
for dest_folder_finetune, dest_folder_relab in zip(finetune_datasets, relab_datasets):
copy(file, dest_folder_finetune)
copy(file, dest_folder_relab)
every 20 iterations, I am having a permission denied problem. The stack, looks something like:
Traceback (most recent call last):
File "/home/revan/boosting_classifier_with_games/dataset_creator.py", line 72, in <module>
main()
File "/home/revan/boosting_classifier_with_games/dataset_creator.py", line 24, in main
create_test_and_relab(list_of_subfolders)
File "/home/revan/boosting_classifier_with_games/dataset_creator.py", line 66, in create_test_and_relab
copy(file, dest_folder_finetune)
File "/home/revan/anaconda2/envs/pytorch/lib/python2.7/shutil.py", line 119, in copy
copyfile(src, dst)
File "/home/revan/anaconda2/envs/pytorch/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/sun_btbivuchmkkzetpo.jpg'
The 'funny' thing is that I definitely have all permissions for that file. Furthermore, I tried to copy it manually, and I can do it without problem. If I randomize the process, the same file gets copied, but then some other file (after 20 iterations) cannot be copied.
PS: Changing copy to copy2, gives the exact same problem.
Has anyone experienced anything similar in the past? Could it be a Python or a Linux problem?
One of your datasets has a bad folder name, which is setting the destination to the root of the file system.
To just get it working, you can skip when it's trying to copy to the root:
import os
file = os.path.join(subfolder_name, list_of_files[i])
for dest_folder_finetune, dest_folder_relab in zip(finetune_datasets, relab_datasets):
if os.path.abspath(dest_folder_finetune) != "/":
copy(file, dest_folder_finetune)
else:
print("Warning, path {} for dest_folder_finetune writes to the root of the filesystem".format(dest_folder_finetune))
if os.path.abspath(dest_folder_relab) != "/":
copy(file, dest_folder_relab)
else:
print("Warning, path {} for dest_folder_relab writes to the root of the filesystem".format(dest_folder_relab ))
However, if this is more than a live once script, I suggest scrubbing and verifying the dataset beforehand instead.
try with "sudo python filename.py"

"[Errno 13] Access denied" when connecting to USB

So I have been following these documentations so that I can print on my thermal printer through python.
I am running Ubuntu and have the pyusb module installed.
The printer is a Rongta RP58, and it's idVendor and idProduct were found through the lsusb command (0fe6:811e).
Just like in the instructions, I enter:
from escpos.printer import Usb
p = Usb(0x0fe6, 0x811e)
but the error appears
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/testerdell/.local/lib/python2.7/site-packages/escpos/printer.py", line 51, in __init__
self.open()
File "/home/testerdell/.local/lib/python2.7/site-packages/escpos/printer.py", line 62, in open
check_driver = self.device.is_kernel_driver_active(0)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/core.py", line 1061, in is_kernel_driver_active
self._ctx.managed_open()
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/core.py", line 120, in managed_open
self.handle = self.backend.open_device(self.dev)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 786, in open_device
return _DeviceHandle(dev)
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 643, in __init__
_check(_lib.libusb_open(self.devid, byref(self.handle)))
File "/home/testerdell/.local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
In the documentation it suggested to create a rule that grants access, but it hasn't worked for me.
sudo nano /etc/udev/rules.d/99-escpos.rules
is the command I use to edit the file, and this is what's inside
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fe6", ATTRS{idProduct}=="811e", MODE="0664", GROUP="dialout"
after changing anything in that file, I run this code:
sudo service udev restart
I am not sure how else I can give USB access to python.
When using direct root access with
sudo su root
the system says "ImportError: No module named escpos.printer". I wouldn't want to enter the password for root access every single time.
Is there a problem with my udev rules, groups, mode, user permissions?
Any help is greatly appreciated! Thanks in advance :)
Change the mode from 664 to 666 in your udev rule and it will work.

Categories

Resources