How to setup Python at your Mac/OS X in professional way !
Hey fellow coders who are seeking for knowledge and the best practice. I always start any topic by mentioning a short story of mine as it was a motivation to state why i had done it. I happen to have course for AI/ML where I had assignment which was having an AI that works as detector for defect items from production line, similar to what Co-cola use for their products. However, it was real mess for me where I had to setup python , install Keras library, install Anaconda UI, and many to name that I had to have them in my project , BUT ! That was real disaster where i ended up to setup them and make sure that i need to download different version of python. It was painful till i was looking for solution that can make switching easier, Pyenv https://github.com/pyenv/pyenv#understanding-path !
Using this will make your life wayyyyyy easier, so let us kick-off and get it install at your OS X machine.
1- Setup Brew
Most of the majority of developers who use OS X they are taking it as must in their setup to manage the packages ,so I highly recommend it. Easy, open up your terminal and type this down:
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
you can get the steps and other documentation from here https://brew.sh/
2- Download Pyenv & Python:
Alright, time has come to install by using our package manager, open-up your terminal and run this command:
brew install pyenv
Great ! now before we go with installation you can run this right quick and see how awesome this package !
pyenv install -l
pyenv install --list
from the date of publishing this article the oldest possible python version is 2.1.3 to 3.10-dev
let us assume that I want to setup 3.7.3 version which it really suits me in my case. Run:
pyenv install 3.7.3
it may take time depending on your connectivity.
I just need to assign the version i want to use by using global method:
pyenv global 3.7.3
There you go, buddy ! we have it, but we still must set it up in our shell/terminal globally. You can add this to your profile weather it is .bash_profile, zsh, or others.
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
If you are lazy one like me, do this where it will inherit the amendment from one profile to another at your machine:
echo source ~/.bash_profile > ~/.zshenv && source ~/.zshenv
Exit your terminal or run
That is all ! you can now use this whenever you want it. However, there is still more you can do with it and also other plugins can be attach within such as,
The END !
Alright my friend, I would love to give more and more but the time has come to finish this article for now. Please refer yourself to my other article for Flutter https://medium.com/ala-alhaj/flutter-how-to-configure-application-in-the-cloud-by-firestore-getx-dio-firebase-c2ebf8e5c6f3