title: Python opencv videocapture fails to open file with python3 but works with python2
body: <p>I've tried numerous things including building from source (both opencv and ffmpeg with codecs) and nothing seems to help.  I have a mp4 file that works fine with the python2.7 environment, but fails to load with python 3.5.</p>
  
  <p>I know I have different builds installed, but I can't figure out why opencv fails to load for the python3.5 environment.  I've checked paths, etc.  I can't find anything amiss.</p>
  
  <p>Python 2.7.12:</p>
  
  <pre><code>Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
  [GCC 5.4.0 20160609] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import cv2
  &gt;&gt;&gt; cv2.__version__
  '3.3.1'
  &gt;&gt;&gt; a=cv2.VideoCapture("Serenity.mp4")
  &gt;&gt;&gt; a.isOpened()
  True
  </code></pre>
  
  <p>Python 3.5.2:</p>
  
  <pre><code>Python 3.5.2 (default, Sep 14 2017, 22:51:06) 
  [GCC 5.4.0 20160609] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import cv2
  &gt;&gt;&gt; cv2.__version__
  '3.3.0'
  &gt;&gt;&gt; a=cv2.VideoCapture("Serenity.mp4")
  &gt;&gt;&gt; a.isOpened()
  False
  </code></pre>
  
  <p>I've done the following:</p>
  
  <ul>
  <li>Uninstalled python and python3, and opencv</li>
  <li>Checked paths to modules</li>
  <li>video plays fine on vlc and ffmpeg has no problems</li>
  <li>test code using python2.7 plays video fine via opencv</li>
  <li>tried answers found here: <a href="https://stackoverflow.com/questions/31040746/cant-open-video-using-opencv">Can&#39;t open video using opencv</a></li>
  <li>Tried this too <a href="https://stackoverflow.com/questions/42325764/python-opencv-videocapture-differences-between-python-2-7-to-python-3-5">Python OpenCV : VideoCapture differences between Python 2.7 to Python 3.5</a></li>
  </ul>
  
  <p>Information on video sample:</p>
  
  <pre><code>ffprobe version 3.4 Copyright (c) 2007-2017 the FFmpeg developers
    built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 20160609
    configuration: --enable-pic
    libavutil      55. 78.100 / 55. 78.100
    libavcodec     57.107.100 / 57.107.100
    libavformat    57. 83.100 / 57. 83.100
    libavdevice    57. 10.100 / 57. 10.100
    libavfilter     6.107.100 /  6.107.100
    libswscale      4.  8.100 /  4.  8.100
    libswresample   2.  9.100 /  2.  9.100
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x3d57b00] stream 0, timescale not set
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Serenity.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 1
      compatible_brands: isomavc1
      creation_time   : 2007-05-30T05:20:31.000000Z
      genre           : Trailer
      artist          : Universal Pictures
      title           : Serenity - HD DVD Trailer
      date            : 2005
    Duration: 00:02:19.71, start: 0.000000, bitrate: 4802 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 4674 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
      Metadata:
        creation_time   : 2007-05-30T05:20:31.000000Z
        handler_name    : GPAC ISO Video Handler
      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
      Metadata:
        creation_time   : 2007-05-30T05:20:34.000000Z
        handler_name    : GPAC ISO Audio Handler
      Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 240x240 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
  </code></pre>
  
  <hr>
  
  <p>Edit:  I've also tried compiling from source using the methods outlined here based on suggestions from the comments (and swapping the .so file):
  <a href="https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/" rel="nofollow noreferrer">https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/</a></p>
  
  <hr>
  
  <p>solved:  After many attempts, I had to just wipe my Lubuntu 16.04.3 system and rebuild it.  See detailed answer below.</p>