Re: [spyder] Error importing OpenCV (works in normal python shell)

4,158 views
Skip to first unread message

David Verelst

unread,
May 10, 2013, 3:07:46 AM5/10/13
to spyder
Hi,

I use spyder (the recently released v2.2 on Arch Linux) with openCV (v2.4.5) successfully. Can you share some more details, like what version of spyder are you running, are you on Mac/Linux/Windows, openCV version, etc. How/where did you install openCV?

Regards,
David


On 10 May 2013 02:02, ftherien <funk...@gmail.com> wrote:
Hi! I recently installed OpenCV. It seems to works correctly in any python shell (idle, or python started on the command line), but in spyder I get the following:

>> import cv2
ImportError: DLL load failed: La procédure spécifiée est introuvable.
(sorry for the french, rough translation would be "Specified procedure could not be found")

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

ftherien

unread,
May 10, 2013, 9:03:14 AM5/10/13
to spyd...@googlegroups.com
Thanks for your reply

Win 7 64 bit
Python 2.7.3 64 bit
Spyder 2.2.0
OpenCV 2.4.5 (compiled myself with vc10 to work with python 64 bit)

My opencv binaries are under C:\opencv\release\bin\Release. I added this dir to my %PATH%, as well as creating an env variable %OPENCV_DIR% that points to C:\opencv\. I copied cv2.pyd to my python27\Lib\site-packages dir. I've also tried adding the Release dir above to PYTHONPATH (in spyder) to see if it would help.

As I said above, everything works in a python interpreter ran from a command prompt, or in IDLE (ran some opencv scripts successfully in both)
Message has been deleted

David Verelst

unread,
May 10, 2013, 1:15:53 PM5/10/13
to spyder
I don't know too much about the sensitivities with respect to Windows. Maybe you could try to see if there is any difference between the PYTHONPATH as seen from Spyder, and the other python consoles? Something like:
>>> import sys
>>> for k in sys.path: print k

For my Linux package, I have following opencv components exposed to a PYTHONPATH aware folder:

/usr/lib/python2.7/site-packages/cv.py

/usr/lib/python2.7/site-packages/cv2.so

Not sure what is going on. On my system there is no other addition to the PYTHONPATH regarding opencv. It seems that adding it to the site-packages folder should be sufficient.

However, Spyder can find the cv2 library, the one you placed in the site-packages dir, because otherwise you should have an import error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2

So this is a bit confusing for me, as it doesn't look like a PYTHONPATH issue? It seems that Spyder finds the cv2.pyd file (there is no import error), but fails to load the proper openCV libraries installed elsewhere. Not sure how the other python consoles manage to figure it out...

Regards,
David

ftherien

unread,
May 11, 2013, 1:32:19 PM5/11/13
to spyd...@googlegroups.com
I did in fact build opencv with qt (4.8.4). I'll run some tests tomorrow see if that could be the problem.

On Friday, May 10, 2013 1:05:43 PM UTC-4, cjgo...@gmail.com wrote:
A shot in the dark: did you build OpenCV with the Qt backend? The Qt DLLs provided by PyQt4 might be incompatible with your OpenCV build.
Using OpenCV from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv works for me with Spyder 2.2

Christoph

ftherien

unread,
May 12, 2013, 4:49:51 PM5/12/13
to spyd...@googlegroups.com
Ok, so here it is:

I had installed the PyQt4 (Qt 4.8.4) binaries from the PyQt site, which include the Qt bins also. My hypothesis is that these binaries were built with MinGW.

I had a separate Qt 4.8.4 install on my computer, that I built with msvc2010. My OpenCV install (also built with msvc2010) was linked against this install.

My hypothesis is that the PtQt-included Qt binaries were somehow not compatible with the Qt binaries from my install. This is reinforced by the fact that you cannot build opencv with msvc linked to qt binaries built with mingw - cmake will give an error to that effect (produces incompatible code).

Anyways, I built PyQt4 from source, with msvc2010, linked against my existing Qt binaries. Seems to work fine now. Thanks to all!

C12D13

unread,
Oct 31, 2013, 10:17:05 AM10/31/13
to spyd...@googlegroups.com
I have the same problem when running spyder from Python27\Scripts\spyder.bat.

The problem goes away when running spyder from Python27\Lib\site-packages\spyderlib\spyder.pyc

Not sure why, but it works. Good luck!


JG

unread,
Apr 12, 2017, 10:08:40 PM4/12/17
to spyder
Same issue here. Ended up statically linking Qt to OpenCV DLL (cv2.pyd), which also solved the problem.
Reply all
Reply to author
Forward
0 new messages