Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV 2.3.1 Python with Eclipse shows synatx errors but still runs

I followed this guide to setup OpenCV 2.3.1 in Python 2.7 with Eclipse.

I also copied the libraries into my python folder:

http://i.snag.gy/J9RrC.jpg

Here is my Hello World program which runs correctly (creates a named window and displays the image) but Eclipse still shows syntax errors

Eclipse showing syntax errors

every error says "Undefined variable from import"

Here are my python settings for this project:

http://i.snag.gy/KBXiB.jpg http://i.snag.gy/KfTpF.jpg

Have I setup my PythonPath incorrectly? How can i get Eclipse to work properly?

Thanks

like image 454
josh Avatar asked Feb 17 '12 00:02

josh


1 Answers

I had the same problem, everything ran correctly even though there were undefined import errors all over the place. I eventually solved it by adding 'cv' to the list of Forced Builtins: Window > Preferences > Pydev > Interpreter - Python > Forced Builtins > New.

This is how I came across the solution:

How to use code completion into Eclipse with OpenCV

I hope that this may help you too.

like image 75
hjweide Avatar answered Oct 06 '22 17:10

hjweide