ThomasMcLeod
ThomasMcLeod

Reputation: 7769

python error in opencv installation

I am attempting to install the opencv library in Linux and I get the following error in a log generated by a python script:

Traceback (most recent call last):
  File "/tmcleod/opencv-2.4.4/modules/java/generator/gen_javadoc.py", line 257, in ?
    import hdr_parser
  File "/tmcleod/opencv-2.4.4/modules/java/generator/../../python/src2/hdr_parser.py", line 641
    decl[1] = ": " + ", ".join([b if "::" in b else self.get_dotted_name(b).replace(".","::") for b in bases])
                                   ^
SyntaxError: invalid syntax

Here is the command in the makefile that is causing the error:

cd /tmcleod/opencv-2.4.4/release/modules/java && /usr/bin/python2 /tmcleod/opencv-2.4.4/modules/java/generator/gen_javadoc.py --modules core,imgproc,objdetect,features2d,video,highgui,ml,calib3d,photo,contrib /tmcleod/opencv-2.4.4/modules/java/generator/src/java /tmcleod/opencv-2.4.4/release/modules/java 2>"/tmcleod/opencv-2.4.4/release/modules/java/get_javadoc_errors.log"

I do not know why I need to generate java docs on the installation of a C++ library, but the issue is causing the build to fail. Any help appreciated.

Upvotes: 0

Views: 1419

Answers (1)

ThomasMcLeod
ThomasMcLeod

Reputation: 7769

The problem here was that cmake was finding an older version (2.4) of the python executable that did not understand this construct. The workaround is to pass cmake a path to python. From opencv extract directory:

$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=./build -D PYTHON_EXECUTABLE=/tmcleod/Python-2.7.3/python ..
$ make
$ make install

Upvotes: 3

Related Questions