I have a script that is called from DJango, but it doesn't execute instead it gives PermissionError: [Errno 13] Permission denied. I'm using CMD on Windows as admin.
Here is how I'm calling:
cmd = os.path.join(os.getcwd(), "D:/commerceTest/cs50-commerceM/Photo/GFPGAN/inference_gfpgan.py --upscale 2 --model_path D:/commerceTest/cs50-commerceM/Photo/GFPGAN/experiments/pretrained_models/ --test_path inputs/whole_imgs/GFPGANCleanv1-NoCE-C2.pth --save_root D:/commerceTest/cs50-commerceM/Photo/GFPGAN/results")
#os.system("python D:/commerceTest/cs50-commerceM/Photo/GFPGAN/inference_gfpgan.py --upscale 2 --model_path D:/commerceTest/cs50-commerceM/Photo/GFPGAN/experiments/pretrained_models/ --test_path inputs/whole_imgs/GFPGANCleanv1-NoCE-C2.pth --save_root D:/commerceTest/cs50-commerceM/Photo/GFPGAN/results")
os.system('{} {}'.format('python', cmd))
Here is the message I received:
Traceback (most recent call last):
File "D:\commerceTest\cs50-commerceM\Photo\GFPGAN\inference_gfpgan.py", line 98, in <module>
main()
File "D:\commerceTest\cs50-commerceM\Photo\GFPGAN\inference_gfpgan.py", line 52, in main
restorer = GFPGANer(
File "D:\commerceTest\cs50-commerceM\Photo\GFPGAN\gfpgan\utils.py", line 60, in __init__
loadnet = torch.load(model_path)
File "D:\Users\rapha\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\serialization.py", line 594, in load
with _open_file_like(f, 'rb') as opened_file:
File "D:\Users\rapha\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "D:\Users\rapha\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\serialization.py", line 211, in __init__
super(_open_file, self).__init__(open(name, mode))
PermissionError: [Errno 13] Permission denied: 'D:/commerceTest/cs50-commerceM/Photo/GFPGAN/experiments/pretrained_models/'
I can only guess here but the error that you are getting is because Python is trying to open a directory as a file (which won't work).
It looks like the path that you are passing in to --model_path is a directory but torch.load() expects a file, that would explain it.
I would start with understanding what exactly the script inference_gfpgan.py does and how it works.
Related
Permisson error appears and the model stops working. When I searched it, it said it was an access or path setting problem, but I don't know which part to fix.
Full error message
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\groove2groove\models\roll2seq_style_transfer.py", line 407, in
main()
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\groove2groove\models\roll2seq_style_transfer.py", line 401, in main
args.func(experiment, args)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\groove2groove\models\roll2seq_style_transfer.py", line 186, in run_midi
pipeline.save(sequences, args.output_file)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\groove2groove\io.py", line 303, in save
midi_io.note_sequence_to_midi_file(sequence, path)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\note_seq\midi_io.py", line 217, in note_sequence_to_midi_file
copyfile(temp_file.name, output_file)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
PermissionError: [Errno 13] Permission denied: 'C:\Users\user\AppData\Local\Temp\tmp853_r9ai'
style_transfer.py
def run_midi(self, args):
pipeline = MidiPipeline(source_path=args.source_file, style_path=args.style_file,
bars_per_segment=args.bars_per_segment, warp=True)
sequences = self._run_cli(args, pipeline)
pipeline.save(sequences, args.output_file)
io.py
def save(self, sequences, path):
sequence = self._seq_pipeline.postprocess(sequences)
midi_io.note_sequence_to_midi_file(sequence, path)
I've seen a lot of people saying that there's a problem if the path is a folder.
python -m groove2groove.models.roll2seq_style_transfer --logdir 'D:\groove2groove\experiments\v01_drums' run-midi \
--sample --softmax-temperature 0.6 \
content.mid style.mid output.mid
However, the path to the folder was never entered when the terminal entered it...
One of the task is failed due to FileNotFoundError: [Errno 2] No such file or directory. Below are parts of log that might be helpful.
[2020-10-17 21:15:59,086] {bash_operator.py:113} INFO - Tmp dir root location:
/tmp
[2020-10-17 21:15:59,090] {bash_operator.py:136} INFO - Temporary script location:
/tmp/airflowtmpf1umw2qp/task_ugp_ugo_ux_east_eop_vldkgwtbl2z
...
[2020-10-20 06:18:03,803] {bash_operator.py:161} INFO - Command exited with return code 0
[2020-10-20 06:18:03,805] {taskinstance.py:1150} ERROR - [Errno 2] No such file or
directory: '/tmp/airflowtmpf1umw2qp/task_ugp_ugo_ux_east_eop_vldkgwtbl2z'
Traceback (most recent call last):
File "/airflow/etl/pyenv/pyugp/lib/python3.7/site-packages/airflow/models/taskinstance.py",
line 984, in _run_raw_task
result = task_copy.execute(context=context)
File "/airflow/etl/pyenv/pyugp/lib/python3.7/site-
packages/airflow/operators/bash_operator.py", line 165, in execute
raise AirflowException("Bash command failed")
File "/airflow/etl/software/python37/lib/python3.7/tempfile.py", line 500, in __exit__
self.close()
File "/airflow/etl/software/python37/lib/python3.7/tempfile.py", line 507, in close
self._closer.close()
File "/airflow/etl/software/python37/lib/python3.7/tempfile.py", line 444, in close
unlink(self.name)
FileNotFoundError: [Errno 2] No such file or directory:
'/tmp/airflowtmpf1umw2qp/task_ugp_ugo_ux_east_eop_vldkgwtbl2z'
As it is shown in the log, the Temporary script was created on 17-10-2020 and the error was thrown on 20-10-2020, during this period it was waiting for a cfg and a data file which will be used for validation.
I got always the message: PermissionError: [WinError 32] The process cannot access the file because it is being used by another process
Yes, i read [enter link description here][1] but it didn't help me.
# pdf_merger2.py
import glob,os,shutil
os.getcwd()
from PyPDF2 import PdfFileMerger
os.chdir(r"auf_comp")
def merger(output_path, input_paths):
pdf_merger = PdfFileMerger()
file_handles = []
for path in input_paths:
pdf_merger.append(path)
with open(output_path, 'wb') as fileobj:
pdf_merger.write(fileobj)
if __name__ == '__main__':
paths = glob.glob('*.pdf')
paths.sort()
merger('data.pdf', paths)
shutil.move(r"data.pdf", r"../data.pdf")
edit:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 788, in move
os.rename(src, real_dst)
PermissionError: [WinError 32] PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'data.pdf' -> '../data.pdf'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\typ42\Downloads\latextest\merge.py", line 22, in <module>
shutil.move(r"data.pdf", r"../data.pdf")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 803, in move
os.unlink(src)
PermissionError: [WinError 32] PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'data.pdf'
[1]: https://stackoverflow.com/questions/27215462/permissionerror-winerror-32-the-process-cannot-access-the-file-because-it-is
I am trying to use a Python scrip that converts Latex to a png. The library is at https://github.com/cptdeadbones/pytex2png.
When I run the command python examples.py I get the following error:
Traceback (most recent call last):
File "./examples.py", line 14, in <module>
main()
File "./examples.py", line 11, in main
pytex2png.convert("examples/"+file,"output/"+file+".png")
File "/Users/kekearif/Desktop/pytex2png-master/pytex2png.py", line 44, in convert
make_transparent_bg(output,display)
File "/Users/kekearif/Desktop/pytex2png-master/pytex2png.py", line 31, in make_transparent_bg
exe_command(command_line)
File "/Users/kekearif/Desktop/pytex2png-master/pytex2png.py", line 11, in exe_command
p = subprocess.Popen(args,stdout=subprocess.PIPE)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 390, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1024, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory'
What does this error mean? Is it an error in how the arguments are being passed?
From the source:
def exe_command(cmd, display=False):
args = shlex.split(cmd)
if(display):
p = subprocess.Popen(args)
else:
p = subprocess.Popen(args,stdout=subprocess.PIPE)
p.wait()
Is there a mistake in the function above?
I hope you have followed the Usage as describe here : Usage which create Makefile.
Have you check the Disclaimers ?? It says the following :
This code was devloped and tested on a Linux based system. I have no
idea if it will work on another system. If you have tested it on
another system, please let me know.
Traceback (most recent call last):
File "C:/my_python/read1.py", line 3, in <module>
book = open_workbook('Book1.xls',on_demand=True)
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 449, in open_workbook
ragged_rows=ragged_rows,
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 941, in biff2_8_load
f = open(filename, open_mode)
IOError: [Errno 2] No such file or directory: 'Book1.xls'
I am getting this error message in python while trying to open an excel sheet.....How can i solve this ?
Either make sure Book1.xls is in "C:\my_python\", which is also where your script is, or use the full path to where Bool1.xls is located. For example:
book = open_workbook('C:\\Users\\Jeeva\\Documents\\Book1.xls',on_demand=True)