Inicio > Programación > Opencv: Usando la nueva interfaz de python

Opencv: Usando la nueva interfaz de python

Domingo, 15 de agosto de 2010 Dejar un comentario Ir a comentarios

Ya os he hablado en alguna ocasión de la librería OpenCV con las que suelo trabajar. Con C/C++ nunca he tenido problemas para usarla ya que más o menos me manejo con estos lenguajes y el compilador gcc en GNU/Linux, pero al intentar probar la interfaz de programación de las OpenCV con python me encontré con el problema de que python no encontraba el módulo necesario (cv). El error que me aparecía en la consola al intentar importar el módulo era el siguiente:

>>> import cv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv

Buscando un poco por internet encontré que la solución consiste simplemente en añadir la siguiente línea a nuestro fichero $HOME/.bashrc:

export PYTHONPATH=/usr/local/lib/python2.6/site-packages/

Quizás sea algo lógico para la gente que está acostumbrada a trabajar con python, pero a mi me ha disgustado bastante el hecho de que este pequeño detalle no se comente en absoluto en la documentación de las OpenCV.

I’ve already spoken to you in other posts about the OpenCV library with which I usually work. With C/C++ I’ve never have problems to use it because of I get by with these languages and the gcc compiler  more o less in GNU/Linux, but when I tried to use the new python interface of the OpenCV library I found the problem that python could not find the required module (cv). This is the error message that python threw me:

>>> import cv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv

Surfing on internet I found one solution that consist of adding this line to our $HOME/.bashrc file:

export PYTHONPATH=/usr/local/lib/python2.6/site-packages/

Maybe it is logical for people who are use to working with python but I’m a little upset with the fact that this issue isn’t commented in the OpenCV documentation.

GD Star Rating
loading...
Opencv: Usando la nueva interfaz de python, 10.0 out of 10 based on 1 rating
Share
Categories: Programación Tags: ,
  1. Lunes, 16 de agosto de 2010 a las 10:30 | #1
    GD Star Rating
    loading...

    Python rules!

  2. Jay
    Jueves, 9 de septiembre de 2010 a las 07:19 | #2
    GD Star Rating
    loading...

    It seems a very common problem for Mac/Unix machine. And also, it seems official python IDLE (2.6x) still can’t work with OpenCV python API because of the architecture incompatible. (doesn’t support X86_64 on Mac). I guess you are using mac build-in python on terminal environment. That is okay for opencv python api. Btw, FYI, it will be much painful by using another lib “pyopencv” which provide advanced opencv lib.

  3. Jabumon
    Miércoles, 23 de febrero de 2011 a las 04:32 | #3
    GD Star Rating
    loading...

    ¿Y que se hace en windows cuando ocurre este error?

  4. Miércoles, 23 de febrero de 2011 a las 08:18 | #4
    GD Star Rating
    loading...

    Hola Jabumon,

    Apenas programo en Windows, pero el equivalente a este proceso en el SO de microsoft sería definir una variable de entorno PYTHONPATH con el mismo valor. Las variables de entorno se definen desde “Panel de control” -> “Sistema” -> “Configuración avanzada” (más o menos). Siento no poder serte más de ayuda en este tema.

  1. Sin trackbacks aún.