I need a progress to show during file download for Python 3.
I have seen a few topics on Stackoverflow, but considering that I’m a noob at programming and nobody posted a complete example, just fractions of it, or the one that I can make work on Python 3, none are good for me…
additional info:
ok, so i have this:
from urllib.request import urlopen
import configparser
#checks for files which need to be downloaded
print(' Downloading...')
file = urlopen(file_url)
#progress bar here
output = open('downloaded_file.py','wb')
output.write(file.read())
output.close()
os.system('downloaded_file.py')
script is run through python command line
There is
urlretrieve()that downloads an url to a file and allows to specify a reporthook callback to report progess:Here’s a GUI progress bar:
On Python 3.3
urlretrieve()has differentreporthookinterface (see issue 16409). To workaround it, you could access the previous interface viaFancyURLopener:To update the progress bar within the same thread, you could inline
urlretrieve()code: