0

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.

3
  • I had the same exact issue. I only needed the python library, so as a work-around, I copied the compiled shared object file (cv2.so), into my working directory. Commented Mar 28, 2013 at 2:54
  • @Moshe, so is it an error in the python script? Commented Mar 28, 2013 at 3:00
  • Possibly, although that syntax appears to be legal for Python 2.7, so I don't know what is wrong (I used [b if b in 'abc' else 'X' for b in 'abcdefgh'] as a small test case). Commented Mar 28, 2013 at 3:59

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.