How to setup Python at your Mac/OS X in professional way !

Photo by Jefferson Santos on Unsplash

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 !

Steps

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
process of downloading / installing by brew

Great ! now before we go with installation you can run this right quick and see how awesome this package !

pyenv install -l

or

pyenv install --list

from the date of publishing this article the oldest possible python version is 2.1.3 to 3.10-dev

nice screenshot of what you can install, more than this ofc!

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.

3- Setup:

I just need to assign the version i want to use by using global method:

pyenv global 3.7.3
set the version and check as well

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

exec "$SHELL"

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, virtualenv.

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

--

--

--

Security Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to delete any object in a Word DOCX document in Python

Shifting from open source to custom software — How it drives value in an enterprise

Profit With Programming..💸

How to set up an auto-renewing wildcard SSL certificate using Certbot and Acme DNS for an Nginx…

Some Important Topics of Algorithm

Clusters and workloads migration from Hadoop 2 to Hadoop 3

The Ultimate deployment guide for atoti on AWS with Amazon EC2

The Only Time I Failed a Tech Interview

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ala Alhaj

Ala Alhaj

Security Engineer

More from Medium

Software — the “OG” as-a-Service model

Performance comparison: InfluxDB, TimescaleDB, IoTDB, TDEngine, OpenTSDB v.s. TickTock

Open Source for your law practice

Announcing Our Documentation Site for Wallaroo Users