Install Keras and OpenCV | Computer Vision with Keras

Computer vision with Keras, the purpose of this series is to use Keras as a tool to go deep into computer vision. I decided to use Keras because it is the most intuitive API to build a Convolutional neural network with python.

Keras is great when you want to build computer vision models or algorithms in a fast way because with a few lines you go straight to the point with the result you want to achieve.

In this tutorial of the EP. 1 we will see:

  1. Install Pycharm, the best IDE for creating a good environment
  2. Install the right version of Python
  3. Install Keras with OpenCV

computervision with keras

1. Install Pycharm

To use Computer vision with Keras and program as efficiently as possible you need to have a good development environment. In my opinion, the Pycharm IDE is the best for this purpose but you can use whatever you like.

Go to and download the installer for your OS version. In this tutorial, we will use the Community Edition version

IDE Pycharm community edition

Follow the installation instructions until you get to the Finish button

2. Install the right version of Python

Most likely you already have python installed on your computer but in any case, I recommend that you install exactly the same version that I am using. Because sometimes different versions work differently.

Go to and download version 3.9.13

Follow the installation instructions

python installation

until you see the “Setup was successful” text

3. Install Keras with OpenCV

Before installing Keras we open our Pycharm development environment and create a new project: File -> New Project then set all the parameters as in the image below. I have put computervisionkeras as the project name and set Python 3.9 as the interpreter.

pycharm envirorment

As soon as the creation of the virtual environment finishes you can create the python file. Right-click on the project name then New -> Python File

new python file

Computer vision with Keras installation problem

We are ready to write the first line of code

from tensorflow import keras

but of course, we get this error because we haven’t installed the library yet. We need Tensorflow which is the framework from google and Keras is an API that works on top of TensorFlow.

run keras error

We then proceed with the installation by clicking on File -> Settings

Pycharm Settings

As soon as the new window opens, find the name of your project in the menu on the left. Extend and click on Python Interpreter, then click on the gear on the right.

install tensorflow on pycharm

Tensorflow on pycharm

Type tensorflow and install the package exactly like in the image


OpenCV on Pycharm

Type opencv-python and install the package exactly like in the image


Final test

If there are no errors you can write the code

from tensorflow import keras
import cv2


and run it to see if everything goes correctly. As you can see in the image below there are no errors and it prints the versions of the installed libraries on the screen

final test computer vision keras installation

Learn to build Computer Vision Software easily and efficiently.

This is a FREE Workshop where I'm going to break down the 4 steps that are necessary to build software to detect and track any object.

Sign UP for FREE