How to install OpenCV 2.4.7 for Python , Ubuntu












0















I am going to use a code shared on GitHub on facial feature extraction. This code has OpenCV 2.4.7 and Python 2.7 dependencies. I tried OpenCV 3.4, but it didn't work. This code uses cv2.Boost() which is not found in OpenCV 3.4.
Also, pypi only support OpenCV 3x. I couldn't install OpenCV 2.4.7 by pip install.



Please let me know how I can install OpenCV 2.4.7 for Python? I prefer to install it in a Conda virtual environment.



O.S: Ubuntu 16;
I can use Windows 10 too.










share|improve this question



























    0















    I am going to use a code shared on GitHub on facial feature extraction. This code has OpenCV 2.4.7 and Python 2.7 dependencies. I tried OpenCV 3.4, but it didn't work. This code uses cv2.Boost() which is not found in OpenCV 3.4.
    Also, pypi only support OpenCV 3x. I couldn't install OpenCV 2.4.7 by pip install.



    Please let me know how I can install OpenCV 2.4.7 for Python? I prefer to install it in a Conda virtual environment.



    O.S: Ubuntu 16;
    I can use Windows 10 too.










    share|improve this question

























      0












      0








      0








      I am going to use a code shared on GitHub on facial feature extraction. This code has OpenCV 2.4.7 and Python 2.7 dependencies. I tried OpenCV 3.4, but it didn't work. This code uses cv2.Boost() which is not found in OpenCV 3.4.
      Also, pypi only support OpenCV 3x. I couldn't install OpenCV 2.4.7 by pip install.



      Please let me know how I can install OpenCV 2.4.7 for Python? I prefer to install it in a Conda virtual environment.



      O.S: Ubuntu 16;
      I can use Windows 10 too.










      share|improve this question














      I am going to use a code shared on GitHub on facial feature extraction. This code has OpenCV 2.4.7 and Python 2.7 dependencies. I tried OpenCV 3.4, but it didn't work. This code uses cv2.Boost() which is not found in OpenCV 3.4.
      Also, pypi only support OpenCV 3x. I couldn't install OpenCV 2.4.7 by pip install.



      Please let me know how I can install OpenCV 2.4.7 for Python? I prefer to install it in a Conda virtual environment.



      O.S: Ubuntu 16;
      I can use Windows 10 too.







      python opencv ubuntu install






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 3:40









      MohammadMohammad

      64




      64
























          2 Answers
          2






          active

          oldest

          votes


















          1














          I think you could build the OpenCV from source, so you can choose the branch (version) you want to use:



          sudo apt-get install build-essential

          sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

          sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

          cd ~
          git clone https://github.com/opencv/opencv.git
          cd opencv
          git checkout 2.4
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
          make -j7
          sudo make install


          Good luck!






          share|improve this answer



















          • 1





            However, I suggest using the latest version of OpenCV if possible, which is surely more powerful.

            – Howard GENG
            Nov 26 '18 at 5:52











          • Thanks. How can I import the built OpenCV in Spyder or PyCharm running in a conda virtual environment?

            – Mohammad
            Nov 26 '18 at 7:09











          • It should compile the OpenCV library with its support extension of Python. You should be able to use it as the following: import cv2

            – Howard GENG
            Nov 26 '18 at 11:19



















          0














          pip install opencv-python==2.4.7


          For python3 try:



          pip3 install opencv-python==2.4.7


          However, before you install opencv, have numpy and matplotlib installed.



          pip install numpy

          pip install matplotlib





          share|improve this answer
























          • Thanks, I installed numpy and matplotlib. I tried "pip install opencv-python==2.4.7", but I got the error message: "Could not find a version that satisfies the requirement opencv-python==2.4.7 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18) No matching distribution found for opencv-python==2.4.7"

            – Mohammad
            Nov 26 '18 at 4:48













          • It seems OpenCV 2.4 version is no longer supported on the distribution repo.

            – Howard GENG
            Nov 26 '18 at 5:37













          • @HowardGENG my bad. Should I delete my answer? As it is no longer applicable.

            – Azazel
            Nov 26 '18 at 13:15











          • It is up to you. You answer works well for other versions.

            – Howard GENG
            Nov 26 '18 at 21:18













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474508%2fhow-to-install-opencv-2-4-7-for-python-ubuntu%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I think you could build the OpenCV from source, so you can choose the branch (version) you want to use:



          sudo apt-get install build-essential

          sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

          sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

          cd ~
          git clone https://github.com/opencv/opencv.git
          cd opencv
          git checkout 2.4
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
          make -j7
          sudo make install


          Good luck!






          share|improve this answer



















          • 1





            However, I suggest using the latest version of OpenCV if possible, which is surely more powerful.

            – Howard GENG
            Nov 26 '18 at 5:52











          • Thanks. How can I import the built OpenCV in Spyder or PyCharm running in a conda virtual environment?

            – Mohammad
            Nov 26 '18 at 7:09











          • It should compile the OpenCV library with its support extension of Python. You should be able to use it as the following: import cv2

            – Howard GENG
            Nov 26 '18 at 11:19
















          1














          I think you could build the OpenCV from source, so you can choose the branch (version) you want to use:



          sudo apt-get install build-essential

          sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

          sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

          cd ~
          git clone https://github.com/opencv/opencv.git
          cd opencv
          git checkout 2.4
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
          make -j7
          sudo make install


          Good luck!






          share|improve this answer



















          • 1





            However, I suggest using the latest version of OpenCV if possible, which is surely more powerful.

            – Howard GENG
            Nov 26 '18 at 5:52











          • Thanks. How can I import the built OpenCV in Spyder or PyCharm running in a conda virtual environment?

            – Mohammad
            Nov 26 '18 at 7:09











          • It should compile the OpenCV library with its support extension of Python. You should be able to use it as the following: import cv2

            – Howard GENG
            Nov 26 '18 at 11:19














          1












          1








          1







          I think you could build the OpenCV from source, so you can choose the branch (version) you want to use:



          sudo apt-get install build-essential

          sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

          sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

          cd ~
          git clone https://github.com/opencv/opencv.git
          cd opencv
          git checkout 2.4
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
          make -j7
          sudo make install


          Good luck!






          share|improve this answer













          I think you could build the OpenCV from source, so you can choose the branch (version) you want to use:



          sudo apt-get install build-essential

          sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

          sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

          cd ~
          git clone https://github.com/opencv/opencv.git
          cd opencv
          git checkout 2.4
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
          make -j7
          sudo make install


          Good luck!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 5:36









          Howard GENGHoward GENG

          5338




          5338








          • 1





            However, I suggest using the latest version of OpenCV if possible, which is surely more powerful.

            – Howard GENG
            Nov 26 '18 at 5:52











          • Thanks. How can I import the built OpenCV in Spyder or PyCharm running in a conda virtual environment?

            – Mohammad
            Nov 26 '18 at 7:09











          • It should compile the OpenCV library with its support extension of Python. You should be able to use it as the following: import cv2

            – Howard GENG
            Nov 26 '18 at 11:19














          • 1





            However, I suggest using the latest version of OpenCV if possible, which is surely more powerful.

            – Howard GENG
            Nov 26 '18 at 5:52











          • Thanks. How can I import the built OpenCV in Spyder or PyCharm running in a conda virtual environment?

            – Mohammad
            Nov 26 '18 at 7:09











          • It should compile the OpenCV library with its support extension of Python. You should be able to use it as the following: import cv2

            – Howard GENG
            Nov 26 '18 at 11:19








          1




          1





          However, I suggest using the latest version of OpenCV if possible, which is surely more powerful.

          – Howard GENG
          Nov 26 '18 at 5:52





          However, I suggest using the latest version of OpenCV if possible, which is surely more powerful.

          – Howard GENG
          Nov 26 '18 at 5:52













          Thanks. How can I import the built OpenCV in Spyder or PyCharm running in a conda virtual environment?

          – Mohammad
          Nov 26 '18 at 7:09





          Thanks. How can I import the built OpenCV in Spyder or PyCharm running in a conda virtual environment?

          – Mohammad
          Nov 26 '18 at 7:09













          It should compile the OpenCV library with its support extension of Python. You should be able to use it as the following: import cv2

          – Howard GENG
          Nov 26 '18 at 11:19





          It should compile the OpenCV library with its support extension of Python. You should be able to use it as the following: import cv2

          – Howard GENG
          Nov 26 '18 at 11:19













          0














          pip install opencv-python==2.4.7


          For python3 try:



          pip3 install opencv-python==2.4.7


          However, before you install opencv, have numpy and matplotlib installed.



          pip install numpy

          pip install matplotlib





          share|improve this answer
























          • Thanks, I installed numpy and matplotlib. I tried "pip install opencv-python==2.4.7", but I got the error message: "Could not find a version that satisfies the requirement opencv-python==2.4.7 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18) No matching distribution found for opencv-python==2.4.7"

            – Mohammad
            Nov 26 '18 at 4:48













          • It seems OpenCV 2.4 version is no longer supported on the distribution repo.

            – Howard GENG
            Nov 26 '18 at 5:37













          • @HowardGENG my bad. Should I delete my answer? As it is no longer applicable.

            – Azazel
            Nov 26 '18 at 13:15











          • It is up to you. You answer works well for other versions.

            – Howard GENG
            Nov 26 '18 at 21:18


















          0














          pip install opencv-python==2.4.7


          For python3 try:



          pip3 install opencv-python==2.4.7


          However, before you install opencv, have numpy and matplotlib installed.



          pip install numpy

          pip install matplotlib





          share|improve this answer
























          • Thanks, I installed numpy and matplotlib. I tried "pip install opencv-python==2.4.7", but I got the error message: "Could not find a version that satisfies the requirement opencv-python==2.4.7 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18) No matching distribution found for opencv-python==2.4.7"

            – Mohammad
            Nov 26 '18 at 4:48













          • It seems OpenCV 2.4 version is no longer supported on the distribution repo.

            – Howard GENG
            Nov 26 '18 at 5:37













          • @HowardGENG my bad. Should I delete my answer? As it is no longer applicable.

            – Azazel
            Nov 26 '18 at 13:15











          • It is up to you. You answer works well for other versions.

            – Howard GENG
            Nov 26 '18 at 21:18
















          0












          0








          0







          pip install opencv-python==2.4.7


          For python3 try:



          pip3 install opencv-python==2.4.7


          However, before you install opencv, have numpy and matplotlib installed.



          pip install numpy

          pip install matplotlib





          share|improve this answer













          pip install opencv-python==2.4.7


          For python3 try:



          pip3 install opencv-python==2.4.7


          However, before you install opencv, have numpy and matplotlib installed.



          pip install numpy

          pip install matplotlib






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 3:56









          AzazelAzazel

          878




          878













          • Thanks, I installed numpy and matplotlib. I tried "pip install opencv-python==2.4.7", but I got the error message: "Could not find a version that satisfies the requirement opencv-python==2.4.7 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18) No matching distribution found for opencv-python==2.4.7"

            – Mohammad
            Nov 26 '18 at 4:48













          • It seems OpenCV 2.4 version is no longer supported on the distribution repo.

            – Howard GENG
            Nov 26 '18 at 5:37













          • @HowardGENG my bad. Should I delete my answer? As it is no longer applicable.

            – Azazel
            Nov 26 '18 at 13:15











          • It is up to you. You answer works well for other versions.

            – Howard GENG
            Nov 26 '18 at 21:18





















          • Thanks, I installed numpy and matplotlib. I tried "pip install opencv-python==2.4.7", but I got the error message: "Could not find a version that satisfies the requirement opencv-python==2.4.7 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18) No matching distribution found for opencv-python==2.4.7"

            – Mohammad
            Nov 26 '18 at 4:48













          • It seems OpenCV 2.4 version is no longer supported on the distribution repo.

            – Howard GENG
            Nov 26 '18 at 5:37













          • @HowardGENG my bad. Should I delete my answer? As it is no longer applicable.

            – Azazel
            Nov 26 '18 at 13:15











          • It is up to you. You answer works well for other versions.

            – Howard GENG
            Nov 26 '18 at 21:18



















          Thanks, I installed numpy and matplotlib. I tried "pip install opencv-python==2.4.7", but I got the error message: "Could not find a version that satisfies the requirement opencv-python==2.4.7 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18) No matching distribution found for opencv-python==2.4.7"

          – Mohammad
          Nov 26 '18 at 4:48







          Thanks, I installed numpy and matplotlib. I tried "pip install opencv-python==2.4.7", but I got the error message: "Could not find a version that satisfies the requirement opencv-python==2.4.7 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18) No matching distribution found for opencv-python==2.4.7"

          – Mohammad
          Nov 26 '18 at 4:48















          It seems OpenCV 2.4 version is no longer supported on the distribution repo.

          – Howard GENG
          Nov 26 '18 at 5:37







          It seems OpenCV 2.4 version is no longer supported on the distribution repo.

          – Howard GENG
          Nov 26 '18 at 5:37















          @HowardGENG my bad. Should I delete my answer? As it is no longer applicable.

          – Azazel
          Nov 26 '18 at 13:15





          @HowardGENG my bad. Should I delete my answer? As it is no longer applicable.

          – Azazel
          Nov 26 '18 at 13:15













          It is up to you. You answer works well for other versions.

          – Howard GENG
          Nov 26 '18 at 21:18







          It is up to you. You answer works well for other versions.

          – Howard GENG
          Nov 26 '18 at 21:18




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474508%2fhow-to-install-opencv-2-4-7-for-python-ubuntu%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)