You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I kept getting the following error after running the initial download method, below are both the example code I ran and Traceback I got back:
from mega import Mega
mega = Mega()
m = mega.login('<USERNAME>',
'<PASSWORD>')
files = m.find('archive.zip')
m.download(files, "D:\\Documents\\")
Traceback (most recent call last):
File "C:\Users\Gpx45\Documents\Programs\python\downloader\main.py", line 14, in <module>
m.download(files, "D:\\Documents\\")
File "C:\Users\Gpx45\AppData\Local\Programs\Python\Python310\lib\site-packages\mega\mega.py", line 564, in download
return self._download_file(file_handle=None,
File "C:\Users\Gpx45\AppData\Local\Programs\Python\Python310\lib\site-packages\mega\mega.py", line 745, in _download_file
shutil.move(temp_output_file.name, output_path)
File "C:\Users\Gpx45\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 836, in move
os.unlink(src)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\Gpx45\\AppData\\Local\\Temp\\megapy_emosqh_9'
Which I though it strange being that the download stream wasn't closed before it tried to move the file into the specified directory.
After looking online for a bit I found that someone had a similar problem and they fixed it by adding temp_output_file.close() function above the shutil.move() function.
I applied the fix to line 745 and it worked like a charm.
I kept getting the following error after running the initial download method, below are both the example code I ran and Traceback I got back:
Which I though it strange being that the download stream wasn't closed before it tried to move the file into the specified directory.
After looking online for a bit I found that someone had a similar problem and they fixed it by adding
temp_output_file.close()
function above theshutil.move()
function.I applied the fix to line 745 and it worked like a charm.
Here is the SO link:
https://stackoverflow.com/questions/68465210/problem-downloading-mega-files-with-python/68465437#68465437
The text was updated successfully, but these errors were encountered: