How To Install PIP In Python On Mac

Mohammed Babakr
3 min readMar 18, 2024

--

Credits: Image from: Youtube.com/@edurekaIN

How to install Python, NumPy, Matplotlib, MoviePy, Psycopg2 and Pillow on MacOS

Python, renowned for its simplicity and versatility, has become a cornerstone in the toolkit of every data analyst. However, its true power lies in its expansive ecosystem of libraries, offering specialized functionalities to streamline data analysis workflows. From numerical computations with NumPy to data visualization with Matplotlib, and from video editing with MoviePy to database interaction with Psycopg2, these libraries empower data analysts to tackle diverse challenges with ease. In this blog, we’ll explore the installation process for essential Python libraries on MacOS, equipping aspiring data analysts with the tools they need to thrive in the dynamic world of data analysis.

Explanation of the Terminal on Mac:

1. Open Terminal and type “python” to check the Python version (e.g., Python 3.9.7).
2. Close Terminal, reopen it, and create a Python environment in a folder.
3. Use “ls” in Terminal to navigate to the Downloads directory.
4. Type “cd Downloads” to move to the Downloads directory.
5. Create a Python virtual environment using Python 3.9 (e.g., “Python 3.9 -m venv PipPython”).
6. Check visually in the Downloads directory for the created folder named “PipPython.”
7. Navigate to the newly created folder by typing “cd PipPython” in Terminal.
8. Upgrade pip to the latest version by typing “pip3 install — upgrade pip” in Terminal.

9. Install any desired library, e.g., NumPy, by typing “pip3 install PyODBC” in Terminal.

Explanation of the Visual Studio Code installation process on Mac:

1. Create a new project in Visual Studio Code and add a Python file named “PracticePython.py”
2. Encounter an error message stating “import pandas could not be resolved.”
3. Open a new terminal within Visual Studio Code and create a virtual environment for the project.
4. Activate the virtual environment and install the pandas package using pip.

pip3 install pandas

5. Successfully run the Python script using the pandas library in Visual Studio Code, indicating resolution of the issue.

Psycopg2

If you encounter an error while installing Psycopg2, use the following command:

pip3 install psycopg2-binary

--

--

Mohammed Babakr

Data Analyst 📊 | PostgreSQL | SQL | Ms Excel | Google Certified Data Analyst