Progress Bars in Python Terminal

  Рет қаралды 105,015

NeuralNine

NeuralNine

Күн бұрын

Пікірлер: 149
@Sinke_100
@Sinke_100 2 жыл бұрын
chr(9608) for filing bar and chr(9617) for blank
@mvuto137
@mvuto137 Жыл бұрын
I was eight months late, and all I had to offer was a sad, chr(219) lol Thanks for the filled in version.
@aeyyatal
@aeyyatal 2 жыл бұрын
If you run it in PyCharm, in Run window, below the play icon is a cog icon -> under "execution" you can select "Emulate terminal in output console" . This will make the progressbar render properly (also realy usefull if you stuff from the rich libary).
@fakezpred
@fakezpred 2 жыл бұрын
Holy crap thanks for this tip.
@SirFloIII
@SirFloIII 2 жыл бұрын
in python 3 the division int / int returns a float automatically. if you want integer division, you can use //.
@carlosmspk
@carlosmspk 2 жыл бұрын
If you clicked this video looking for an already made progress bar that you can use straight away, use the "tdqm" package. It's generic, lightweight, and very good for performance, and comes with time estimation by default!
@SpaghettDev
@SpaghettDev 2 жыл бұрын
Just a heads up, you can use os.system("") with an empty string argument to display colors in a cmd prompt
@Wald246
@Wald246 2 жыл бұрын
how does that work?
@wrng-i9f
@wrng-i9f 2 жыл бұрын
@@Wald246 dont do this
@Victor_Marius
@Victor_Marius 2 жыл бұрын
came here to point the exact same thing
@Victor_Marius
@Victor_Marius 2 жыл бұрын
@@Wald246 os.system attemts to call an external command and it changes the settings of the terminal. It is like calling colorama.init() and it works with a real command like cls. You can use this trick on windows to avoid the use of colorama or other library (of course you'll have to know the escape sequences: \033[0m; - to reset all, \033[ (30-37 | 90-97 - foreground); (40-47 | 100-107 - background)m example: os.system("cls") # or just os.system("") print("\033[94;103m< bright blue on bright yellow >\033[0m < normal text >") And also works in windows 10 CMD (Command Prompt). But calling external commands (specially OS dependent) it is not a good ideea and should stick to colorama.init(). Also I like using the VT escape sequences because there are a lot more than what colorama has, like for moving the cursor around (\033[nA, \033[nB and \033[nC, where n is a natural number), erasing lines (\033[0K and \033[0J) or changiing the terminal title (print("\033]0;My Title\007", end=""))
@ankushbhagatofficial
@ankushbhagatofficial 11 ай бұрын
you can simply do with Ansi code: print("\33[92mHello, World\33[0m")
@benlong1062
@benlong1062 2 жыл бұрын
That was fun to follow along with, somewhat simple (or at least not overly complicated), and the result looks great! Thanks!
@vest2240
@vest2240 2 жыл бұрын
Had been looking for something like this for a while, your videos are awesome.
@michaelv6304
@michaelv6304 2 жыл бұрын
All these years I never knew that print(..., end=' ') will actually do a carriage return to the same line in a Windows console, lol. THANKS!
@sudoggo
@sudoggo 10 ай бұрын
You don't need to do index + 1. enumerate function takes an optional argument `start` that defaults to 0. So you can just do enumerate(iterable, 1)
@BautyParra
@BautyParra 2 жыл бұрын
small video and to the point in a simple way, love it! Thanks for this
@maurolimaok
@maurolimaok 10 ай бұрын
I don´t know how to code yet. First steps on Odin, but I bookmarked the channel. Thanks a lot for the videos!
@lunyalina
@lunyalina 2 жыл бұрын
In fact CMD can display colors like a Unix terminal (however it won't render italics or bold or any font transforms), you just need to set a registery key called TerminalLevel to 1 Here is the command to do so reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 00000001 stands for "Carage return" Have a great day - 0x454d505459
@vaisakh_km
@vaisakh_km 2 жыл бұрын
@name undefined.... why you are EMPTY :)
@DFPercush
@DFPercush 2 жыл бұрын
This can be done programmatically without affecting the whole system by using windows api functions handle = GetStdHandle(STD_OUTPUT_HANDLE) # ((DWORD) -11) SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING) # (0x0004).
@lunyalina
@lunyalina 2 жыл бұрын
@@vaisakh_km ;)
@SpaghettDev
@SpaghettDev 2 жыл бұрын
you do know you can just use os.system("") with an empty string and that'll activate colors in a cmd right?
@BlueberryCats_
@BlueberryCats_ 2 жыл бұрын
That moment where i was thinking about this this morning, and now it’s top of my recommendation list .-.
@manometer7854
@manometer7854 2 жыл бұрын
Thanks a million for this video! I was just looking for such a solution ... and you saved my day! Thx, thx, thx!
@harrytsang1501
@harrytsang1501 2 жыл бұрын
If you are just looking to add a progress bar to your program, you can wrap an iterator in tqdm.tqdm(). It shows iterations per second and expected finish time
@manometer7854
@manometer7854 2 жыл бұрын
@@harrytsang1501 indeed - amazing! Thx for this hint!
@ben-brady
@ben-brady 2 жыл бұрын
tqdm is really good loading bar package it adjusts automatically, is performant, easy to use and provide nice infothat also includes performance optimizations so it doesn't slow down your program Example: from tqdm import tqdm import time for x in tqdm(range(100)): time.sleep(0.01) 21%|█████████▍ | 21/100 [00:02
@misterwafflezzz
@misterwafflezzz 2 жыл бұрын
Yes, stick to the stuff written in c/c++ when utlizing Python
@AhmedIsam
@AhmedIsam 2 жыл бұрын
Pssst: tqdm means `progress` in Arabic, (taqadam ) in case you ever wondered.
@ben-brady
@ben-brady 2 жыл бұрын
I always thought it was a bunch of random letters, thanks for gifting me with this knowledge.
@MagnusAnand
@MagnusAnand 2 жыл бұрын
Dude, this video was super cool !!
@ReadieFur
@ReadieFur 2 жыл бұрын
I made a similar thing in C# in the past but the fun came when having to write code to not make the lines move to different parts of the screen upon console resize.
@jeanmi8184
@jeanmi8184 2 жыл бұрын
Voilà là, vous me faites plaisir
@nbamol5453
@nbamol5453 2 жыл бұрын
Bro coming with sick projects 🥵🔥🔥
@Imdazedandconfuzed
@Imdazedandconfuzed 2 жыл бұрын
The terminal can be run from PyCharm. The bar in the bottom left hand side that says “Version Control, TODO, Problems, Terminal, Python Packages, Python Console” Click the Terminal tab.
@jackfr0st486
@jackfr0st486 2 жыл бұрын
Perfect just what i was looking for... Btw, do you know how to get the progressbar used in the latest pip3 command. I think that would be a lot cooler.
@nachoherrera
@nachoherrera 2 жыл бұрын
in cmd (or windows terminal) you can go thru all subdirectories in one command "cd Desktop\Programming\NeuralNine\Python\Current". Also you can autocomplete subdir name with tab
@rusty989
@rusty989 2 жыл бұрын
Why are you not using TQDM
@thienviet3429
@thienviet3429 Жыл бұрын
Thank you that you created for me a skill bar :D
@paulus_de_gross5996
@paulus_de_gross5996 Жыл бұрын
you can display the progressbars in pycharm by going to the run-config of the script and then enabeling "Emulate terminal in output console" at "Execution"
@BrandonJacobson
@BrandonJacobson 2 жыл бұрын
I'm assuming you can use this or tqdm and pass it to a GUI library like Tkinter to get a non-command line progress bar?
@pouyatoutounchy1238
@pouyatoutounchy1238 4 ай бұрын
Thank you for the great tutorial. I have done this type of progress bar and in some cases used tqdm, which makes life much easier. However, my question is how can I show the progress in asyncio? what I mean is when you trigger the asyncio.run and it is doing the asyncio.gather to actually complete the asynchronous task, how can I show the progress of each task? something like docker which shows the progress of each image download separately.
@mrmuranga
@mrmuranga 2 жыл бұрын
you rock.... trying to keep up with the videos... awesome stuff...👍🏿thanks please cover more of opencv comparing facial images..I already saw the fingerprint example
@devbites77
@devbites77 2 жыл бұрын
Useful stuff and to the point. I like your style.
@melvilli69
@melvilli69 2 жыл бұрын
it happens when the window doesn't have enough width. change it to maximized mode or move it into a new workspace with enough room
@kernelpanic2927
@kernelpanic2927 Жыл бұрын
Good tutorial, thanks!
@hydraxmoi
@hydraxmoi 2 жыл бұрын
Hello, can you show us how to implement graphics in python? Your python videos are great. Many thanks!
@crackedatcurry
@crackedatcurry 2 жыл бұрын
NeuralNine ON TOP
@sankaranbaskar6165
@sankaranbaskar6165 2 жыл бұрын
sir, how to stop a progress bar at a particular value ?
@maxxxy910
@maxxxy910 2 жыл бұрын
Colorama does work in default cmd but you have to use colorama.init() somewhere in your script first.
@tban8905
@tban8905 7 ай бұрын
I like that guy. Already watched the vim videos. 👍🏻
@juancardona722
@juancardona722 Жыл бұрын
Amazing! Thank you a loads.
@BadSeymur
@BadSeymur 2 жыл бұрын
On line 16 you dont need to make that extra calculation every time in the loop just give enumerate a starting point of one - for i, x in enumerate(numbers, 1): and you are good to go. Same is for len(numbers) you dont want to make it every loop to go and find how long is the list make a var before the loop and use that.Thats all extra calculation that you dont want to do on every loop in real life and slow your code...
@obed818
@obed818 2 жыл бұрын
Very nice thanks, actually i think you can do all that maybe in a cooler way with curses (or cursed dont remember) from standard library , color also for the terminal which has this functionality
@Sinke_100
@Sinke_100 2 жыл бұрын
I managed to do the same with colorama, curses and sty, this colorama is quite fine aproach, for now i used pydroid and with each one had similar issues, i will try it on linux, curses is most complicated
@obed818
@obed818 2 жыл бұрын
@@Sinke_100 ah okay nice to know, i finished reading the documentation of curse the day before this video came out, didn’t realize it was more complicated than this
@lunyalina
@lunyalina 2 жыл бұрын
I did the same but using escape sequences for colors and cursor movements. So didn't need any external lib.
@Sinke_100
@Sinke_100 2 жыл бұрын
How is that done?
@alainrouleau
@alainrouleau 2 жыл бұрын
Very interesting, thanks! 👍
@nestorospina
@nestorospina 2 жыл бұрын
What is the difference of this program with the library tqrm ??
@SirFloIII
@SirFloIII 2 жыл бұрын
tqdm is just way better as you don't have to do any housekeeping yourself, just wrap the interator
@hernanalbertolaborde5889
@hernanalbertolaborde5889 Жыл бұрын
Great video, thanks. How can do the same for parallel tasks?
@mylabszone
@mylabszone 2 жыл бұрын
great content, great didactic. Congrats!
@kharthigeyan
@kharthigeyan 2 жыл бұрын
why not simply use tqdm?.
@lunyalina
@lunyalina 2 жыл бұрын
You may not always want to be dependent on external libs. Or you might want to do it yourself because you need a simple progress bar.
@leoliu2079
@leoliu2079 2 жыл бұрын
@@lunyalina then why use pandas? Just use list
@driouichelmahdi
@driouichelmahdi 2 жыл бұрын
Great videos THX
@Rejgan318
@Rejgan318 2 жыл бұрын
def progress_bar(progress, total, symbol='█', width=100): print(f'{symbol * int(width * progress / total):.
@Victor_Marius
@Victor_Marius 2 жыл бұрын
In windows terminal you do not need to call colorama.init()? Btw CMD supports VT sequences and coloured output with colorama.
@xyr0sTv
@xyr0sTv Жыл бұрын
Why do you use " " at the start of the print and also at the end instead of just using it just with the parameter end=" "? Isn't it the same?
@TheBeast-lu9qm
@TheBeast-lu9qm 2 жыл бұрын
use tqdm for this
@TomKnudsen
@TomKnudsen 2 жыл бұрын
Could you please make a video on how to download weather i.e. download METAR reports from different station using i.e. ICAO or IATA codes?
@soshimee
@soshimee 2 жыл бұрын
What if you have a very small terminal that wraps the progress bar? Shouldn't it fit to the terminal?
@Smaxy_
@Smaxy_ 2 жыл бұрын
You can also use the tqdm library on python for easier progress bars
@avo_k
@avo_k 2 жыл бұрын
this should be top com, no need to reinvent the wheel
@breazfreind402
@breazfreind402 2 жыл бұрын
but it is really educational and informative , this is one of the rare videos showing how to make progress bars. Why should he "reinvent the wheel" of trying to produce the same videos?
@Ownedyou
@Ownedyou 2 жыл бұрын
How would you handle a condition where process fails and the progress bar can't reach 100%?
@m4gg197
@m4gg197 2 жыл бұрын
fun fact: you can run it in pycharm if you choose to emulate the command prompt in your interpreter configuration
@leonardopangaio5574
@leonardopangaio5574 2 жыл бұрын
First of all, thx about the video. But i need some help to make a function that can display more than 1 progress bar, to use in more than 1 loop and that could be shown even during the program is printing in the console. Could you make a new video showing how to update this function?
@albertocaraveo7891
@albertocaraveo7891 2 жыл бұрын
Hello, If I have to print multiple progress bar? How can I do it?
@MrT0mer
@MrT0mer 2 жыл бұрын
Could you explain how to use and what is pyinsxtractor and uncompyle6?
@rnseby
@rnseby 2 жыл бұрын
Hello, Get video. I was able to get the CMD to display the colors by using the adding the code colorama.init() at the start. And then the yellow and green popped up. Didn't even need to close the CMD window. After adding the one line and rerun the script and the colors appeared. Again thanks,
@alienslullaby
@alienslullaby 2 жыл бұрын
love it!
@arielspalter7425
@arielspalter7425 2 жыл бұрын
This is super cool. Is there a way to used it when using a pandas function (for example read_excel) where the loop is implemented by the function and not by yourself so you cannot report progress?
@Ruhrpottpatriot
@Ruhrpottpatriot 2 жыл бұрын
use tqmd. You then can use `for i in tqdm(range(10000)):` to automatically get a progress bar.
@cgpmth6449
@cgpmth6449 2 жыл бұрын
I want the percent number to be in middle of the progress bar. How can i do it?
@tihon4979
@tihon4979 2 жыл бұрын
Nice! But how about awesome python library - rich? There is a progress bar too.
@spozniony5499
@spozniony5499 2 жыл бұрын
Do you can make video about progress bars in kivy
@swizzler
@swizzler 2 жыл бұрын
This is odd, everything else I've read said that before you can implement progress bars, you have to make your python program multi-threaded and make sure to dedicate your background process to another thread, but you didn't do that, is that incorrect information?
@mtmak9
@mtmak9 2 жыл бұрын
Amazing ! :)
@mubelotix
@mubelotix 2 жыл бұрын
Wait you are using windaube ?
@bshsb3038
@bshsb3038 2 жыл бұрын
make a full in detail tutorial about rich library
@m4rt_
@m4rt_ 2 жыл бұрын
1:55 I haven't seen that been used a lot, I usually do: (100 / total) * progress
@renegroulx7029
@renegroulx7029 2 жыл бұрын
Everytime I tried pip install nothing happens. Syntax error: invalid syntax.
@melvilli69
@melvilli69 2 жыл бұрын
Nice intro.
@ykartd
@ykartd 2 жыл бұрын
I see the bar is printed in every loop... why does a new bar print over a previous one?
@Victor_Marius
@Victor_Marius 2 жыл бұрын
because he uses the cariage return character " "
@devbites77
@devbites77 2 жыл бұрын
For me, it is displaying the bar multiple times; not once. Anyway to solve this?
@jyvben1520
@jyvben1520 2 жыл бұрын
your terminal window is not wide enough
@circuit6896
@circuit6896 2 жыл бұрын
It's giving me a Syntax error with this: "numbers [x * 5 for x in range(2000, 3000)]" Copied the code I think pretty much exactly but could be wrong, here's the code: import math def progress_bar(progress, total): precent = 100 * (progress / float(total)) bar = ' ' * int(percent) + '-' * (100 - int(percent)) print(f" |{bar}| {percent:.2f}%", end = " ") numbers [x * 5 for x in range(2000, 3000)] results = [] progress_bar(0, len(numbers)) for i, x in enumerate(numbers): results.append(math.factorial(x)) progress_bar(i + 1, len(numbers))
@breazfreind402
@breazfreind402 2 жыл бұрын
yeah you are missing an equal sign between numbers and "[x*5...]".
@circuit6896
@circuit6896 2 жыл бұрын
Thank you both, if i get around to finding the file again ill update how it went
@burakbulama
@burakbulama 2 жыл бұрын
thank you
@andresantana9148
@andresantana9148 2 жыл бұрын
I wish I could give 1000s of likes. Thank you very much.
@MAX_JVCR
@MAX_JVCR 2 жыл бұрын
Great!!!
@moe__________
@moe__________ 2 жыл бұрын
What IDE software do you use
@wiztech2683
@wiztech2683 2 жыл бұрын
pycharm
@simplegametutorials1341
@simplegametutorials1341 2 жыл бұрын
Rich Library => does the same but quickly
@hell0kitje
@hell0kitje 2 жыл бұрын
next time code whole universe in phyton ;)
@maneth3448
@maneth3448 2 жыл бұрын
lmfao
@harshjain8345
@harshjain8345 2 жыл бұрын
😂💀
@InfamousVEVO
@InfamousVEVO 2 жыл бұрын
Without any imports.
@ed223-p5g
@ed223-p5g 2 жыл бұрын
does it work on ipython
@finsflexin
@finsflexin 2 жыл бұрын
It would be soooo much faster if you just used the user’s volume settings as the progress bar.
@finsflexin
@finsflexin 2 жыл бұрын
@Jamie 🏳️‍🌈 it’s flawless
@Pyth0g
@Pyth0g 4 ай бұрын
Great vid, but why not just use ansi color codes
@ruthvikas
@ruthvikas 2 жыл бұрын
Well the colours didn't work on cmd but worked in PyCharm terminal for me...
@Victor_Marius
@Victor_Marius 2 жыл бұрын
in cmd use colorama.init() just once after the import (or before the first color printing)
@falconash
@falconash 2 жыл бұрын
How in the hell did i reach here... Fav anyways, who knows in the future.
@21Mayhem
@21Mayhem 2 жыл бұрын
u look like the guy from hxh that fights with coins
@philtoa334
@philtoa334 2 жыл бұрын
Thx.
@spprakash76
@spprakash76 7 ай бұрын
Nice
@JNET_Reloaded
@JNET_Reloaded 2 жыл бұрын
ok so wheres the link to the code?
@Thauan7020
@Thauan7020 5 ай бұрын
nice, muito bonito ❣❤‍🩹
@Havirgem
@Havirgem 2 жыл бұрын
tqdm
@leoliu2079
@leoliu2079 2 жыл бұрын
tqdm?
@wuhlheide
@wuhlheide 2 жыл бұрын
My colors do not change
@The_Super_Musician
@The_Super_Musician Жыл бұрын
SOURCE CODE PLS
@nano_redstone
@nano_redstone 2 жыл бұрын
Or you could just use the tqdm package 🤷
@subhankarchakraborty3866
@subhankarchakraborty3866 2 жыл бұрын
Hello Nuralnine, please make a video on "How to automate Gmail using Gmail API". PLEASE 🙏
@ianliu88
@ianliu88 2 жыл бұрын
import tqdm
@thanatosor
@thanatosor 2 жыл бұрын
now try that on Rust
@0znzw
@0znzw 2 жыл бұрын
▨▬▮ squares :)
@matteokrstic5900
@matteokrstic5900 2 жыл бұрын
import rich and you are done
@wajahatirfan8908
@wajahatirfan8908 2 жыл бұрын
👍
@klintkrossa6885
@klintkrossa6885 2 жыл бұрын
chr(9608)
Easy Python Progress Bars with tqdm
14:30
Rob Mulla
Рет қаралды 46 М.
Unlocking your CPU cores in Python (multiprocessing)
12:16
mCoding
Рет қаралды 309 М.
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 12 МЛН
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,5 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 10 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 6 МЛН
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 402 М.
New divisibility rule! (30,000 of them)
26:51
Stand-up Maths
Рет қаралды 318 М.
The intro to Docker I wish I had when I started
18:27
typecraft
Рет қаралды 255 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 815 М.
Best 10 Items I Tested in 2024!
20:12
Project Farm
Рет қаралды 291 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,6 МЛН
The most important Python script I ever wrote
19:58
John Watson Rooney
Рет қаралды 208 М.
Dash Bootstrap Spinner & Progress Bar
27:18
Charming Data
Рет қаралды 19 М.
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 12 МЛН