During OpenCV installation "unable to fetch some archives" error obtained

i use command -
sudo apt-get install build-essential cmake pkg-config
this throws error -
unable to fetch some archives
raspbian.mirror.net.in/raspbian/raspbian stretch/main armhf cmake armhf 3.7.2-1
i have tried using apt-get update command
apt-get upgrade command
my /etc/apt/sources.list file looks like -
deb-src http://raspbian.raspberrypi.org/raspbian strech main contrib non-free
my /etc/resolv.conf looks like -
Please help I am stuck and I have to install Open CV for starting with Image processing work

Hi @shivani.karol,

1st Method

You can install it with conda, which is a bit cleaner if you ask me - it’s more transparent than the following way. This the package here:

The problem with conda is that it’s slow, I’ve had problems with it when installing packages (say bugs that would delete the installed packages without notice).

2nd One

The next option is to use these bunch of commands that will surely get yours installed - it’s just that it’s a bit much to install.

sudo apt-get update -qq && \
    sudo apt-get install libgtk2.0-dev libgtk-3-dev -y --no-install-recommends

sudo apt-get install -y --no-install-recommends \
    libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev \
    libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
    libxvidcore-dev libx264-dev \
    libatlas-base-dev gfortran \
    openexr libilmbase12 libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libqtgui4 libqt4-test

sudo pip3 install opencv-python

I recommend you go this way.

3rd Way

The last way to install it and the hardest is to build the package. Here’s a rather lengthy tutorial done by Adrian that walks you through this process.

This is all you need to do to get opencv installed.

Thank you!

Here is a summary of that way (approach I used last time):

OpenCV Install

From:  https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/

$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev
$ sudo apt-get install libgtk2.0-dev libgtk-3-dev
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python2.7-dev python3-dev

go to https://opencv.org find latest version number (Feb27,2018=3.4.1)

$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
$ unzip opencv.zip
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.4.1.zip
$ unzip opencv_contrib.zip

install pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
$ sudo python3 get-pip.py

Hopefully you are not hitting an interesting issue I ran into earlier this year where the onboard WiFi kept declaring files didn’t exist for apt-get update. I had to add a WiFi dongle, reboot to make the WiFi dongle be wlan0. For some reason, the onboard WiFi as wlan0 would not allow the update, but the WiFi dongle as wlan0 worked great.
(Post on raspberrypi.org forum when this happened)