{
  "id": 18832,
  "title": "ImportError: No module named cv2",
  "url": "/competitions/second-annual-data-science-bowl/discussion/18832",
  "author_name": "",
  "post_date": "2016-02-09T02:27:45.523Z",
  "votes": null,
  "comment_count": 11,
  "views": 22717,
  "content": "<p>Hi guys, I'm pretty new to this and maybe this might be an easy question but I can't seem to import cv2 with the code in the tutorial.  </p>\n\n<p>Any thoughts on how to move forward? </p>\n\n<p>I'm running an AWS instance with g2.8xlarge with the NVIDIA software installed. </p>\n\n<p>Any help would be appreciated! </p>\n\n<p>Thanks, \nJohn</p>",
  "messages": [
    {
      "id": "107297",
      "postDate": "02/09/2016 02:27:45",
      "content": "<p>Hi guys, I'm pretty new to this and maybe this might be an easy question but I can't seem to import cv2 with the code in the tutorial.  </p>\n\n<p>Any thoughts on how to move forward? </p>\n\n<p>I'm running an AWS instance with g2.8xlarge with the NVIDIA software installed. </p>\n\n<p>Any help would be appreciated! </p>\n\n<p>Thanks, \nJohn</p>",
      "rawMarkdown": "Hi guys, I'm pretty new to this and maybe this might be an easy question but I can't seem to import cv2 with the code in the tutorial.  \r\n\r\nAny thoughts on how to move forward? \r\n\r\nI'm running an AWS instance with g2.8xlarge with the NVIDIA software installed. \r\n\r\nAny help would be appreciated! \r\n\r\nThanks, \r\nJohn",
      "votes": null
    },
    {
      "id": "107316",
      "postDate": "02/09/2016 04:48:23",
      "content": "<p>You need to install cv2 in python, but that may not be a very simple task if want do it with CUDA/opencv 3.  Just as a start you can install basic opencv2 version(not sure what flavor linux you are using):\n<a href=\"http://stackoverflow.com/questions/25215102/installing-opencv-for-python-on-ubuntu-getting-importerror-no-module-named-cv2\">http://stackoverflow.com/questions/25215102/installing-opencv-for-python-on-ubuntu-getting-importerror-no-module-named-cv2</a></p>\n\n<p>Just a reference with CUDA I have used this page for fedora (page is for Ubuntu) for opencv3\n<a href=\"http://rolflussi.blogspot.com/2015/09/opencv-with-cuda-on-ubuntu-1404.html\">http://rolflussi.blogspot.com/2015/09/opencv-with-cuda-on-ubuntu-1404.html</a>\nYou don't not need opencv3 for the tutorial.</p>",
      "rawMarkdown": "You need to install cv2 in python, but that may not be a very simple task if want do it with CUDA/opencv 3.  Just as a start you can install basic opencv2 version(not sure what flavor linux you are using):\r\nhttp://stackoverflow.com/questions/25215102/installing-opencv-for-python-on-ubuntu-getting-importerror-no-module-named-cv2\r\n\r\nJust a reference with CUDA I have used this page for fedora (page is for Ubuntu) for opencv3\r\nhttp://rolflussi.blogspot.com/2015/09/opencv-with-cuda-on-ubuntu-1404.html\r\nYou don't not need opencv3 for the tutorial.",
      "votes": null
    },
    {
      "id": "107331",
      "postDate": "02/09/2016 06:33:15",
      "content": "<p>Thanks, Ertuka! </p>\n\n<p>I'm on Ubuntu 14.04.3.  </p>\n\n<p>I believe I already have cv2.  When I try to install it again, it says &quot;Requirement already satisfied.&quot;  </p>\n\n<p>Then, when I open up python in the terminal and type in import cv2, it gives me that error.  I'm using python 2.7.11 with Anaconda. </p>\n\n<p>I also tried installing openCV and have that setup but I just get the error when I try executing the import line of code in python.  </p>\n\n<p>Any other thoughts? </p>\n\n<p>Thanks again!  </p>",
      "rawMarkdown": "Thanks, Ertuka! \r\n\r\nI'm on Ubuntu 14.04.3.  \r\n\r\nI believe I already have cv2.  When I try to install it again, it says \"Requirement already satisfied.\"  \r\n\r\nThen, when I open up python in the terminal and type in import cv2, it gives me that error.  I'm using python 2.7.11 with Anaconda. \r\n\r\nI also tried installing openCV and have that setup but I just get the error when I try executing the import line of code in python.  \r\n\r\nAny other thoughts? \r\n\r\nThanks again!",
      "votes": null
    },
    {
      "id": "107408",
      "postDate": "02/09/2016 17:18:33",
      "content": "<p>Hi John, I had the same issue when trying to install Open CV 3.1, which I built from source on Ubuntu 14.04.  The build/install of OpenCV 3.1 seemed to work fine, but I got the same import error in python.  </p>\n\n<p>To resolve the issue, I had to manually copy the cv2.so from</p>\n\n<p>/path/to/opencv-3.1.0/build/lib</p>\n\n<p>to </p>\n\n<p>/usr/local/lib/python2.7/dist-packages</p>\n\n<p>Of course, the destination will be different for you if you are using Anaconda.  For some reason my OpenCV build didn't do this last step.</p>",
      "rawMarkdown": "Hi John, I had the same issue when trying to install Open CV 3.1, which I built from source on Ubuntu 14.04.  The build/install of OpenCV 3.1 seemed to work fine, but I got the same import error in python.  \r\n\r\nTo resolve the issue, I had to manually copy the cv2.so from\r\n\r\n/path/to/opencv-3.1.0/build/lib\r\n\r\nto \r\n\r\n/usr/local/lib/python2.7/dist-packages\r\n\r\nOf course, the destination will be different for you if you are using Anaconda.  For some reason my OpenCV build didn't do this last step.",
      "votes": null
    },
    {
      "id": "107424",
      "postDate": "02/09/2016 18:47:48",
      "content": "<p>THANK YOU, Quoc Le!  I'll try this out!  </p>",
      "rawMarkdown": "THANK YOU, Quoc Le!  I'll try this out!",
      "votes": null
    },
    {
      "id": "107476",
      "postDate": "02/10/2016 07:19:11",
      "content": "<p>Another thought on my end is possibly the error deriving from using miniconda ... maybe? </p>",
      "rawMarkdown": "Another thought on my end is possibly the error deriving from using miniconda ... maybe?",
      "votes": null
    },
    {
      "id": "107478",
      "postDate": "02/10/2016 08:52:32",
      "content": "<p>UPDATE -- the miniconda was the issue!  Once I removed that directory from my environment and used regular python 2.7, I was able to import cv2 !!! </p>\n\n<p>Thanks everyone for helping! </p>",
      "rawMarkdown": "UPDATE -- the miniconda was the issue!  Once I removed that directory from my environment and used regular python 2.7, I was able to import cv2 !!! \r\n\r\nThanks everyone for helping!",
      "votes": null
    },
    {
      "id": "107516",
      "postDate": "02/10/2016 16:06:17",
      "content": "<p>I am new to this too, this is the first competition I have attempted and I'm stuck at the first hurdle...</p>\n\n<p>I am having the same problem but I do not think it is coursed by the same thing, but please correct me if I'm wrong. </p>\n\n<p>I have pip installed cv2 and the command prompt confirms that it has all been installed correctly but when I run the original piece of code that imports cv2 I get the error that no module names cv2 exists. </p>\n\n<p>I am using standard python 2.7.11 and I am now a little stuck at what could be causing the problem. \nAny ideas?</p>",
      "rawMarkdown": "I am new to this too, this is the first competition I have attempted and I'm stuck at the first hurdle...\r\n\r\nI am having the same problem but I do not think it is coursed by the same thing, but please correct me if I'm wrong. \r\n\r\nI have pip installed cv2 and the command prompt confirms that it has all been installed correctly but when I run the original piece of code that imports cv2 I get the error that no module names cv2 exists. \r\n\r\nI am using standard python 2.7.11 and I am now a little stuck at what could be causing the problem. \r\nAny ideas?",
      "votes": null
    },
    {
      "id": "107864",
      "postDate": "02/13/2016 07:52:11",
      "content": "<p>python, openCV and CUDA together is a big mass on Ubuntu (don't know other distros).</p>\n\n<p>OpenCV is compiled for Python 2.7. When you install it with pip, it will install 2.7.  However, if you run the code with python 3, it will complain that the module is not installed.  </p>\n\n<p>Google Protbuf package, required for Caffe, is compiled with gcc 5.x, and CUDA is restricting itself to gcc &lt;=4.9. </p>\n\n<p>To compile CUDA support, you have to change a header file to enable   5.x. I'm not sure if it has any impact on stability (this change seems to be only solution to issue).</p>",
      "rawMarkdown": "python, openCV and CUDA together is a big mass on Ubuntu (don't know other distros).\r\n\r\nOpenCV is compiled for Python 2.7. When you install it with pip, it will install 2.7.  However, if you run the code with python 3, it will complain that the module is not installed.  \r\n\r\nGoogle Protbuf package, required for Caffe, is compiled with gcc 5.x, and CUDA is restricting itself to gcc <=4.9. \r\n\r\nTo compile CUDA support, you have to change a header file to enable   5.x. I'm not sure if it has any impact on stability (this change seems to be only solution to issue).",
      "votes": null
    },
    {
      "id": "107888",
      "postDate": "02/13/2016 14:14:31",
      "content": "<p>@LeonRussell  It sounds like you have the package installed but it is not on any of the paths python is searching for packages.  You need to find where the file cv2.so is and then append that location to the PYTHONPATH.  </p>",
      "rawMarkdown": "LeonRussell  It sounds like you have the package installed but it is not on any of the paths python is searching for packages.  You need to find where the file cv2.so is and then append that location to the PYTHONPATH.",
      "votes": null
    },
    {
      "id": "107986",
      "postDate": "02/14/2016 16:23:34",
      "content": "<p>I don't garner , that opencv possesses any bearing on model accuracy..</p>",
      "rawMarkdown": "I don't garner , that opencv possesses any bearing on model accuracy..",
      "votes": null
    },
    {
      "id": "108158",
      "postDate": "02/15/2016 22:31:56",
      "content": "<p>Turns out rather than using the link that takes you to the CV2 site it is far easier to just install one of the binaries. This solved all the issues I was having in trying to get this to work. \nThanks for the pointers.</p>",
      "rawMarkdown": "Turns out rather than using the link that takes you to the CV2 site it is far easier to just install one of the binaries. This solved all the issues I was having in trying to get this to work. \r\nThanks for the pointers.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 107316,
      "author_name": "esorar",
      "author_url": "",
      "post_date": "02/09/2016 04:48:23",
      "content": "<p>You need to install cv2 in python, but that may not be a very simple task if want do it with CUDA/opencv 3.  Just as a start you can install basic opencv2 version(not sure what flavor linux you are using):\n<a href=\"http://stackoverflow.com/questions/25215102/installing-opencv-for-python-on-ubuntu-getting-importerror-no-module-named-cv2\">http://stackoverflow.com/questions/25215102/installing-opencv-for-python-on-ubuntu-getting-importerror-no-module-named-cv2</a></p>\n\n<p>Just a reference with CUDA I have used this page for fedora (page is for Ubuntu) for opencv3\n<a href=\"http://rolflussi.blogspot.com/2015/09/opencv-with-cuda-on-ubuntu-1404.html\">http://rolflussi.blogspot.com/2015/09/opencv-with-cuda-on-ubuntu-1404.html</a>\nYou don't not need opencv3 for the tutorial.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107331,
      "author_name": "johngunawan",
      "author_url": "",
      "post_date": "02/09/2016 06:33:15",
      "content": "<p>Thanks, Ertuka! </p>\n\n<p>I'm on Ubuntu 14.04.3.  </p>\n\n<p>I believe I already have cv2.  When I try to install it again, it says &quot;Requirement already satisfied.&quot;  </p>\n\n<p>Then, when I open up python in the terminal and type in import cv2, it gives me that error.  I'm using python 2.7.11 with Anaconda. </p>\n\n<p>I also tried installing openCV and have that setup but I just get the error when I try executing the import line of code in python.  </p>\n\n<p>Any other thoughts? </p>\n\n<p>Thanks again!  </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107408,
      "author_name": "quocnle",
      "author_url": "",
      "post_date": "02/09/2016 17:18:33",
      "content": "<p>Hi John, I had the same issue when trying to install Open CV 3.1, which I built from source on Ubuntu 14.04.  The build/install of OpenCV 3.1 seemed to work fine, but I got the same import error in python.  </p>\n\n<p>To resolve the issue, I had to manually copy the cv2.so from</p>\n\n<p>/path/to/opencv-3.1.0/build/lib</p>\n\n<p>to </p>\n\n<p>/usr/local/lib/python2.7/dist-packages</p>\n\n<p>Of course, the destination will be different for you if you are using Anaconda.  For some reason my OpenCV build didn't do this last step.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107424,
      "author_name": "johngunawan",
      "author_url": "",
      "post_date": "02/09/2016 18:47:48",
      "content": "<p>THANK YOU, Quoc Le!  I'll try this out!  </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107476,
      "author_name": "johngunawan",
      "author_url": "",
      "post_date": "02/10/2016 07:19:11",
      "content": "<p>Another thought on my end is possibly the error deriving from using miniconda ... maybe? </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107478,
      "author_name": "johngunawan",
      "author_url": "",
      "post_date": "02/10/2016 08:52:32",
      "content": "<p>UPDATE -- the miniconda was the issue!  Once I removed that directory from my environment and used regular python 2.7, I was able to import cv2 !!! </p>\n\n<p>Thanks everyone for helping! </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107516,
      "author_name": "leon1233",
      "author_url": "",
      "post_date": "02/10/2016 16:06:17",
      "content": "<p>I am new to this too, this is the first competition I have attempted and I'm stuck at the first hurdle...</p>\n\n<p>I am having the same problem but I do not think it is coursed by the same thing, but please correct me if I'm wrong. </p>\n\n<p>I have pip installed cv2 and the command prompt confirms that it has all been installed correctly but when I run the original piece of code that imports cv2 I get the error that no module names cv2 exists. </p>\n\n<p>I am using standard python 2.7.11 and I am now a little stuck at what could be causing the problem. \nAny ideas?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107864,
      "author_name": "obbenb",
      "author_url": "",
      "post_date": "02/13/2016 07:52:11",
      "content": "<p>python, openCV and CUDA together is a big mass on Ubuntu (don't know other distros).</p>\n\n<p>OpenCV is compiled for Python 2.7. When you install it with pip, it will install 2.7.  However, if you run the code with python 3, it will complain that the module is not installed.  </p>\n\n<p>Google Protbuf package, required for Caffe, is compiled with gcc 5.x, and CUDA is restricting itself to gcc &lt;=4.9. </p>\n\n<p>To compile CUDA support, you have to change a header file to enable   5.x. I'm not sure if it has any impact on stability (this change seems to be only solution to issue).</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107888,
      "author_name": "senecaur",
      "author_url": "",
      "post_date": "02/13/2016 14:14:31",
      "content": "<p>@LeonRussell  It sounds like you have the package installed but it is not on any of the paths python is searching for packages.  You need to find where the file cv2.so is and then append that location to the PYTHONPATH.  </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 107986,
      "author_name": "jordanmicahbennett",
      "author_url": "",
      "post_date": "02/14/2016 16:23:34",
      "content": "<p>I don't garner , that opencv possesses any bearing on model accuracy..</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 108158,
      "author_name": "leon1233",
      "author_url": "",
      "post_date": "02/15/2016 22:31:56",
      "content": "<p>Turns out rather than using the link that takes you to the CV2 site it is far easier to just install one of the binaries. This solved all the issues I was having in trying to get this to work. \nThanks for the pointers.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "107297": "Hi guys, I'm pretty new to this and maybe this might be an easy question but I can't seem to import cv2 with the code in the tutorial.  \r\n\r\nAny thoughts on how to move forward? \r\n\r\nI'm running an AWS instance with g2.8xlarge with the NVIDIA software installed. \r\n\r\nAny help would be appreciated! \r\n\r\nThanks, \r\nJohn",
    "107316": "You need to install cv2 in python, but that may not be a very simple task if want do it with CUDA/opencv 3.  Just as a start you can install basic opencv2 version(not sure what flavor linux you are using):\r\nhttp://stackoverflow.com/questions/25215102/installing-opencv-for-python-on-ubuntu-getting-importerror-no-module-named-cv2\r\n\r\nJust a reference with CUDA I have used this page for fedora (page is for Ubuntu) for opencv3\r\nhttp://rolflussi.blogspot.com/2015/09/opencv-with-cuda-on-ubuntu-1404.html\r\nYou don't not need opencv3 for the tutorial.",
    "107331": "Thanks, Ertuka! \r\n\r\nI'm on Ubuntu 14.04.3.  \r\n\r\nI believe I already have cv2.  When I try to install it again, it says \"Requirement already satisfied.\"  \r\n\r\nThen, when I open up python in the terminal and type in import cv2, it gives me that error.  I'm using python 2.7.11 with Anaconda. \r\n\r\nI also tried installing openCV and have that setup but I just get the error when I try executing the import line of code in python.  \r\n\r\nAny other thoughts? \r\n\r\nThanks again!",
    "107408": "Hi John, I had the same issue when trying to install Open CV 3.1, which I built from source on Ubuntu 14.04.  The build/install of OpenCV 3.1 seemed to work fine, but I got the same import error in python.  \r\n\r\nTo resolve the issue, I had to manually copy the cv2.so from\r\n\r\n/path/to/opencv-3.1.0/build/lib\r\n\r\nto \r\n\r\n/usr/local/lib/python2.7/dist-packages\r\n\r\nOf course, the destination will be different for you if you are using Anaconda.  For some reason my OpenCV build didn't do this last step.",
    "107424": "THANK YOU, Quoc Le!  I'll try this out!",
    "107476": "Another thought on my end is possibly the error deriving from using miniconda ... maybe?",
    "107478": "UPDATE -- the miniconda was the issue!  Once I removed that directory from my environment and used regular python 2.7, I was able to import cv2 !!! \r\n\r\nThanks everyone for helping!",
    "107516": "I am new to this too, this is the first competition I have attempted and I'm stuck at the first hurdle...\r\n\r\nI am having the same problem but I do not think it is coursed by the same thing, but please correct me if I'm wrong. \r\n\r\nI have pip installed cv2 and the command prompt confirms that it has all been installed correctly but when I run the original piece of code that imports cv2 I get the error that no module names cv2 exists. \r\n\r\nI am using standard python 2.7.11 and I am now a little stuck at what could be causing the problem. \r\nAny ideas?",
    "107864": "python, openCV and CUDA together is a big mass on Ubuntu (don't know other distros).\r\n\r\nOpenCV is compiled for Python 2.7. When you install it with pip, it will install 2.7.  However, if you run the code with python 3, it will complain that the module is not installed.  \r\n\r\nGoogle Protbuf package, required for Caffe, is compiled with gcc 5.x, and CUDA is restricting itself to gcc <=4.9. \r\n\r\nTo compile CUDA support, you have to change a header file to enable   5.x. I'm not sure if it has any impact on stability (this change seems to be only solution to issue).",
    "107888": "LeonRussell  It sounds like you have the package installed but it is not on any of the paths python is searching for packages.  You need to find where the file cv2.so is and then append that location to the PYTHONPATH.",
    "107986": "I don't garner , that opencv possesses any bearing on model accuracy..",
    "108158": "Turns out rather than using the link that takes you to the CV2 site it is far easier to just install one of the binaries. This solved all the issues I was having in trying to get this to work. \r\nThanks for the pointers."
  },
  "source": "meta"
}