Мой сайт должен очистить некоторые данные от другого, все работает на моем компьютере.Однажды я помещаю свое приложение на сервер, и эта ошибка возникает.Я изменил разрешение на 777
для папок с полным путем и не работал.Я использую python3
, apache 2.4
на ubuntu 18.10
.
PermissionError at / scrape / [Errno 13] Отказано в доступе: FILENAME
Журнал ошибок:
[Tue Sep 24 20:54:41.981186 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
[Tue Sep 24 20:54:41.981190 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] response = get_response(request)
[Tue Sep 24 20:54:41.981192 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
[Tue Sep 24 20:54:41.981195 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] response = self.process_exception_by_middleware(e, request)
[Tue Sep 24 20:54:41.981198 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
[Tue Sep 24 20:54:41.981201 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Tue Sep 24 20:54:41.981204 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/news/views.py", line 96, in scrape
[Tue Sep 24 20:54:41.981207 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] with open(local_filename, 'wb') as f:
[Tue Sep 24 20:54:41.981211 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] PermissionError: [Errno 13] Permission denied: '4MsktkpTURBXy9kOWRiYWQ4Yzk2ZDkyYjk2YjNiYmRhZjNhNDdiMWQ2NC5qcGeTlQMARc0EAM0CP5MFzQEUzJuVB9kyL3B1bHNjbXMvTURBXy83MWUxOGYwMDNhYWE1ODk3NTIwMmFmNTk0OGZmNmZjMS5wbmcAwgA.jpg'
[Tue Sep 24 20:54:41.981217 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391]
Строка, вызывающая ошибку с:
media_root = '/home/matms/django_project/media_root'
if not image_source_solved.startswith(("data:image", "javascript")):
#exists = os.path.isfile(media_root+image_source_solved)
exists = 1
if exists == 2:
pass
else:
local_filename = image_source_solved.split('/')[-1].split("?")[0]+".jpg"
r = session.get(image_source_solved, stream=True, verify=False)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
f.write(chunk)
current_image_absolute_path = os.path.abspath(local_filename)
shutil.move(current_image_absolute_path, media_root)