When I run a code which imports spynner, I get the following error:

> python .\spynner-test.py
Traceback (most recent call last):
  File ".\spynner-test.py", line 10, in <module>
    import spynner
  File "C:\Anaconda\lib\site-packages\spynner\__init__.py", line 2, in <module>
    from browser import *
  File "C:\Anaconda\lib\site-packages\spynner\browser.py", line 56, in <module>
    from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
ImportError: DLL load failed: The specified procedure could not be found.

A funny thing is that I can import those things in normal python shell without any problem:

> python
Python 2.7.5 |Anaconda 1.9.2 (64-bit)| (default, Jul  1 2013, 12:37:52) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
>>>

But after import spynner fails,

> python
Python 2.7.5 |Anaconda 1.9.2 (64-bit)| (default, Jul  1 2013, 12:37:52) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import spynner
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda\lib\site-packages\spynner\__init__.py", line 2, in <module>
    from browser import *
  File "C:\Anaconda\lib\site-packages\spynner\browser.py", line 56, in <module>
    from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
ImportError: DLL load failed: The specified procedure could not be found.
>>> from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
>>>
有帮助吗?

解决方案

Okay I figured it out. The problem is that spynner first tries to import PySide, and it gets an error in importing QSslConfiguration from PyQt4.QtNetwork. And then it switches to PyQt4, and apparently the previously imported PySide makes the PyQt4 import fail. When I remove the try: part in browser.py I could import spynner fine.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top