Of course! Here is a comprehensive guide to installing and using OpenCV for Python 3.6.

⚠️ Important Note on Python 3.6
First and foremost, it's crucial to understand that Python 3.6 reached its official end-of-life on December 23, 2025. This means:
- No Security Updates: You will not receive any security patches.
- No Bug Fixes: Known bugs will not be fixed.
- Limited Library Support: Many modern libraries, including newer versions of OpenCV, have dropped support for Python 3.6.
Recommendation: If at all possible, you should strongly consider upgrading to a newer, supported version of Python (like 3.8, 3.9, 3.10, or 3.11). This will save you from future headaches and security vulnerabilities.
However, if you absolutely must use Python 3.6, this guide will show you how to get a working version of OpenCV.
Step 1: Prerequisites
Before you install OpenCV, make sure you have the following:

- Python 3.6: You can download it from the official Python website (python.org). Make sure to check the box "Add Python to PATH" during installation.
- pip: Python's package installer. It usually comes pre-installed with Python. You can check by opening a command prompt or terminal and typing
pip --version. - A C++ Compiler: OpenCV is a C++ library, and its Python bindings (
opencv-python) need to be compiled. On Windows, you'll need Microsoft Visual C++ 14.0 or a compatible compiler. The easiest way to get this is by installing Microsoft C++ Build Tools. During installation, make sure to select the "Desktop development with C++" workload.- Download: Visual Studio Build Tools
Step 2: Installation
The best way to install OpenCV for Python 3.6 is using pip. There are two main packages you might need:
opencv-python (Recommended)
This is the most common package. It contains the main OpenCV modules and is pre-compiled for most platforms. This is the best place to start.
Open your command prompt or terminal and run:
pip install opencv-python==4.5.5.64
Why specify a version? Newer versions of opencv-python (e.g., 4.6.0+) dropped support for Python 3.6. The last version to officially support it was 5.5.64. By specifying this version, you ensure compatibility.

opencv-contrib-python (Optional)
This package includes all the modules from opencv-python plus the "contrib" modules, which contain additional algorithms and functionalities that are not part of the core library. If you need features like SIFT, SURF, or extra object detectors, use this one.
pip install opencv-contrib-python==4.5.5.64
Troubleshooting Installation Issues
-
Error:
Could not find a version that satisfies the requirement...- This means the version you're trying to install doesn't have a pre-built "wheel" for your system. You might need to install from source, which is complex and requires a C++ compiler. Stick to the version specified above (4.5.5.64).
-
Error:
Microsoft Visual C++ 14.0 is required...This means you don't have the C++ compiler installed. Follow the instructions in the "Prerequisites" section to install the Microsoft C++ Build Tools.
-
Error:
Permission denied- This is common on macOS/Linux. Try using the
--userflag to install the package only for your user account, not system-wide.pip install opencv-python==4.5.5.64 --user
- This is common on macOS/Linux. Try using the
Step 3: Verification
Once the installation is complete, you should verify that OpenCV is working correctly.
- Open a Python interpreter or a Jupyter Notebook.
- Run the following commands:
import cv2
# Print the OpenCV version
print("OpenCV Version:", cv2.__version__)
# Test reading an image (you can use any image file, e.g., 'my_image.jpg')
# If you don't have an image, you can create a black one.
image = cv2.UMat(240, 320, cv2.CV_8UC3) # Creates a blank black image
cv2.rectangle(image, (10, 10), (300, 200), (0, 255, 0), 3) # Draw a green rectangle
# Display the image in a window
cv2.imshow('Test Image', image)
# Wait for a key press to close the window
cv2.waitKey(0)
# Destroy all windows
cv2.destroyAllWindows()
print("Test successful!")
If this script runs without errors and a window with a green rectangle appears, then your OpenCV for Python 3.6 installation is working perfectly!
Step 4: A Simple "Hello World" Example
Here is a classic example to get you started: loading an image, converting it to grayscale, and saving it.
import cv2
import os
# --- 1. Load an Image ---
# Make sure you have an image file named 'input.jpg' in the same directory
# Or provide the full path to your image file.
image_path = 'input.jpg'
# Check if the image file exists
if not os.path.exists(image_path):
# If not, create a dummy image for demonstration
print(f"'{image_path}' not found. Creating a dummy image.")
dummy_image = cv2.UMat(400, 600, cv2.CV_8UC3)
cv2.rectangle(dummy_image, (50, 50), (550, 350), (255, 0, 0), -1)
cv2.putText(dummy_image, 'OpenCV for Python 3.6', (150, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
cv2.imwrite(image_path, dummy_image)
# Read the image
image = cv2.imread(image_path)
# Check if the image was loaded successfully
if image is None:
print(f"Error: Could not read image from {image_path}")
else:
# --- 2. Convert to Grayscale ---
# The color image has 3 channels (B, G, R). Grayscale has only 1.
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# --- 3. Save the Grayscale Image ---
output_path = 'output.jpg'
cv2.imwrite(output_path, gray_image)
# --- 4. Display the Images ---
cv2.imshow('Original Color Image', image)
cv2.imshow('Grayscale Image', gray_image)
print("Original image saved as:", image_path)
print("Grayscale image saved as:", output_path)
print("\nDisplaying images. Press any key to exit.")
# Wait for a key press to close all windows
cv2.waitKey(0)
cv2.destroyAllWindows()
To run this example:
- Save the code as a Python file (e.g.,
test_opencv.py). - Place an image named
input.jpgin the same folder, or the script will create one for you. - Run the script from your terminal:
python test_opencv.py. - Two windows will appear. Press any key to close them. You will also find an
output.jpgfile in the folder, which is the grayscale version of your image.
