How to install Conda, Python, Jupyter Notebook natively on Macbook M1, M2 (Apple Silicon)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone the purpose of this video is to install and run python on macbook pro m1 or m2 um i'm gonna start right away but before that and i just wanna briefly introduce myself so my name is sajad i have about 10 to 15 years experience programming and i can do programming in 15 languages i'm a senior programmer in working currently working in a korean company um i just watched a lot of tutorials on youtube udemy and i just realized that the majority of these tutorials do not teach the developer how to how how the process is done uh is is they just give the solution to the problem and the the problem with that is if you if you give if if somebody is hungry and you give them a fish to eat then um again they will be hungry and they will come back you for another fish but if you teach them how to catch a fish whenever they are hungry they they can go catch a fish and eat by themselves but what does it mean when it comes to programming it means that you as a programmer should be able to find solutions to your problems using google without as much as possible without a tutorial and that is a very important skill it's you you could call it problem solving skill right so in my all my videos which i'm planning to make a series i'm gonna follow this approach uh to teach you how to become a good developer instead of just giving you a fish to eat so so so i wanna so the purpose is to to run python uh in a jupiter notebook inside a visual studio code on my macbook pro m1 so how do i approach this problem how do i do that so i just put some steps to make it easier for you first we need to install a software called conda in our case we want to install miniforge but what is miniforge and why do we need to install miniforge miniforge is is is is used is is actually a package manager uh used by if if you don't know anaconda let me let me just search online it's easier and and by the way english is not my first language please understand thank you so anaconda is a big platform think of it as a as an ide like visual studio code that many people use for development software development especially using python and r languages but in our case in my case i i love visual studio code and i do everything using visual studio code and then that's how what i'm going to show you so we don't need conda in this in this tutorial but we need something called mini forge and and basically mini forge is a minimal installer for conda con what is kanda kanda is a package manager so if we want to install for example python or some python packages we could use conda but but things are getting confusing right but why do we need mini forge miniforge is actually kanda is specifically built for mac m1 that's what macm one or mac m2 that's why we need uh mini forge so um [Music] without more discussion we i will search mini forge and one brew install what is brew if you don't know what is brew you are in big trouble you definitely need to go learn what is brew and install it on your pc so just go to homebrew website and and read about it it's a package manager for mac so we come back here conda on m1 mac with mini forge i think this is the one that we're looking for we go down you go ahead and read these instructions with homebrew installed open terminal and type okay this is the way we can install miniforge using brew i open terminal don't worry i put all the commands down in the comment section and by the way this is my first uh video i'm a little bit distressed please understand thank you depending on your system speed it could take a while in my case it it took a few seconds so now mini forge is installed so how how how do we check if the if conda is already it is installed correctly so let's just search conda check version command okay you see conda dash v capital let me clean everything okay great now conda is installed now we can use conda to create a virtual environment and install python and the packages that we need so why do we need a virtual environment um i remember when i first started python development it was a little bit confusing for me why would i need a few environment for my environments for my uh development can i can't i just use every package with the latest version of it and just install only one environment on my macbook no the the problem that i think that we have until now with python is we have a lot tons of cool libraries very cool libraries but the problem is that many of these dependencies you will have different dependency conflicts that's why you want to have a separate uh environment for every project make a separate environment install a specific version of python that you need and a specific version of packages that you want for your project that way you will not have dependency conflicts so let's go back to our steps okay uh sorry i removed these so we we just finished installing mini conda and now we want to create virtual environment using conda kanda create virtual in virment so why do i show you the search how how i search on google instead of just showing you the command the reason as i just first mentioned when i started this video that the reason is i want you to become a developer i don't want you to just um solve solve this problem and be stuck in another problem that you cannot find a solution on the on on any videos so conduct create virtual environment i will just click on the first link create virtual environment for python with conda okay check on the installed already checked check conda is up to date we don't need we we just installed condo so we know it's up to date create a virtual environment for your project exactly this is the one we want and if you want to search the python version use this one okay let's just give it a try i know what version i want i want to install python version 3.10 but let's just give it a try probably this command shows us a list of available pythons on conda the python versions that we can install it's gonna take a while exactly yes as you can see we we have a list of python so we're gonna go for the latest version this one and let's go back okay this is the command to install python so we we don't want to install anaconda anaconda again is an ide like visual studio code code but we we're not gonna use it so i'm going to go ahead i want to change the environment name so i push option key on my keyboard and click right here some beginner some beginner um some beginner senior junior i'm sorry some junior developers just go ahead like push left arrow all the way to the place that they want to edit it's not a good practice push option key and just anywhere and then you can easily edit the part that you want just in case you didn't know that environment let's just name it like this environment i like to start my environment with env underline and just let's say environment test python that's this is the name of our project and then here we want to put python version remember we just checked the list of pythons i put it on 3.10 you could go ahead 3.10.5 but if you don't define the last part i guess it's gonna download the latest version of that part so and we don't need anaconda so i remove it and then click enter depending on your internet speed it's going to take a while proceed yes again i'm not trying to um be as efficient as possible teaching you how to quickly solve this problem i'm trying to show you how it is done in real life so here it seems that it's installed correctly to activate this environment use this to deactivate use this okay we want to activate i copy this command using command c i clean using command k paste the command and click enter okay you see i got an error command not found your shell has not been properly con properly configured to use conda activate okay to initialize your shell run this okay and the shell name could be one of these so i i don't know which which shell i'm using right now so how do i know that so google it mac shell current shell check current shell this this should be good so i just go for the first one i usually don't look at the question i just go right away right away to the first answer so i i already had this issue before so i know the answer is to use this command to echo echo dollar zero but if you don't know just go ahead read all this okay i'm gonna copy this command clean everything echo dollar zero okay my shell type is zsh then let's go back to our previous commands you can go to previous commands using up arrow on your keyboard um kanda in it and then z sh this one in your system it could be different like if you're using windows i think it's gonna be power shell or if you're using intel it could be bash just make sure you use echo dollar zero in my case it was zsh okay now it seems that it's done maybe let's let's see now if everything works oh it's not working so oh let me just okay okay okay you see here sometimes these stupid little things um uh just makes it difficult it makes it stressful to be a developer so you see we need to restart the shell i use command q to completely close the terminal and then open it again so now you see okay now it's working and you see this base it means it's working fine and this base means that we are in base environment so we we want to move it we want to activate another environment so i click arrow up again conda activate env test python and click enter now you see the base is changed to d in the new environment name great and we want to also check remember when we installed the environment we also installed python 10 let me show you the command here 3.10 so let's see if python is actually installed correctly check python version command you see just use google as much as you can don't think too much okay it's not efficient to think and use your memory is is gonna you see you're gonna use your brain all day long and if you wanna think about commands it's gonna use your body energy don't do that instead search on google and find the answers as much as you can that that's way more efficient python version and many times it's way faster so okay python is working very much okay and uh what was the next okay we have python we want to install jupyter notebook i just gonna go copy this command conda install jupiter notebook enter so i go for the first result okay it's telling me to create environment activate environment we already did that okay this is the command we're looking for copy so let's see i clean everything on the install jupiter notebook proceed yes it's gonna take a while um if you if your stock if you have any questions just ask in the comments below you know senior developers are very expensive you could think about six digits my salary so but but i'm gonna ask answer your questions for free no money that that's good right no money required so uh seems like the installation is over the reason probably the reason that many senior developers don't do youtube stuff is because it's cheap because it's way you know economically financially it's better to just develop than just make youtube content so so we just installed jupiter notebook let's just run let's just see if we can open jupyter notebook um how to open okay okay remember i told you we're not gonna use we're gonna use visual studio as ide so you should know what is visual studio code it's it's uh an ide very famous one this this is the visual studio code and we wanna i i i like to do everything using visual studio code i do web development app development and python of course and i use every every for every project i use visual studio and i definitely recommend you to go for it give it a try so now so what we want to do is we want to uh we want to open jupyter notebook in in here of course i know the way but the way we want to do it is just googling stuff right so um install python and jupiter vs code i'm just gonna switch i i i didn't i this is the first time i'm searching for this it says that i searched before maybe maybe you see it's been a while a few months ago so jupiter notebooks in vs code let's see how we can install jupyter notebook okay first create a new jupyter notebook using this command let's see i go back here interesting command shift p jupiter okay interesting you you can actually create a new jupiter notebook right away from um using command shift and pd this one that you see here so let me just first open a change like here python test i i want to create a new folder on my desktop for this project python let's just call it python test like this so now i open this python test folder now let's create jupiter notebook using this command oh very interesting seriously so let's just save our jupiter notebook like give it a name like python under underline test enter so this this wasn't the way i used to actually create jupyter notebook i would just go here right click and just test that i pi and b but remembering the extension is also a pain so that i learned another way of doing it interesting so i'm just gonna go ahead remove one of these two okay so now we have this jupiter and and it gives us an arrow right here right down here let me move my okay now you can see the error it says no python interpreter is selected let's click on here it's very intuitive very good i like vs code um here you you you will depending on how many python versions you have on your system you you will see a list of pythons and you definitely want to pick the the environment that we just created like in my case i i named it test python you it could be different for you so i just click it and boom oh also here come and change it to this one okay now now we're good to go let me save this and print welcome to python tutorial by sachat command shift enter shift enter is the easy way to run a command in jupyter notebook inside visual studio code and you could also click on this small play button and as you can see the the python is installed correctly and one thing i forgot was that oh my goodness you you need actually to install python extension and the jupyter note with a notebook extension on your visual studio code i already had it installed so you could see this probably in your case you you would get an error or something like that so python here install this python and also jupyter note oh okay just jupiter there you go install these two extensions and you're good to go thank you so much for watching and see you on next video
Info
Channel: Sajad: Senior Developer
Views: 27,516
Rating: undefined out of 5
Keywords:
Id: lRJ53rPrKD0
Channel Id: undefined
Length: 23min 12sec (1392 seconds)
Published: Mon Jun 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.