Why can't pytest-qt find PyQt for Python 3.4?

497 Views Asked by At

I am using AppVeyor (Think Travis but for Windows) to run some tests again several different versions of Python. The tests depend on PyQt and pytest-qt. In some configurations, pytest-qt can't find PyQt, complaining:

pytest-qt requires either PySide, PySide2, PyQt4 or PyQt5 to be installed

The PyQt5 tests are working, but the tests also need to run older versions of Python, where PyQt4 is required.

Python 2.7, 32-bit

On Python 2.7 (32 bit), I install PyQt with conda:

conda install -q pyqt=4

It successfully installs pyqt-4.11.4-py27_7

Then I install pytest-qt with pip:

pip install pytest pytest-cov pytest-qt

It successfully installs pytest-qt-2.4.0.

Then I run the tests. It's fine.

Python 2.7, 64-bit

Exactly the same story. Works fine.

Python 3.4, 64-bit

This time it installs pyqt 4.11.4-py34_7, plus the same version of pytest-qt, but when the test runs, it crashes out:

py.test tests -v
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\_pytest\main.py", line 174, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\_pytest\config.py", line 957, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\__init__.py", line 628, in call_historic
INTERNALERROR>     res = self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pytestqt\plugin.py", line 187, in pytest_configure
INTERNALERROR>     qt_api.set_qt_api(config.getini('qt_api'))
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pytestqt\qt_compat.py", line 60, in set_qt_api
INTERNALERROR>     raise RuntimeError(msg)
INTERNALERROR> RuntimeError: pytest-qt requires either PySide, PySide2, PyQt4 or PyQt5 to be installed
Command exited with code 3

I tried specifying the environment variable PYTEST_QT_API=pyqt4 or PYTEST_QT_API=pyqt4v2, but it complained:

ImportError: DLL load failed: The specified module could not be found.

I can't figure out what might be different for Python 3.4. What do I need to do to help pytest-qt find the installation of PyQt?

0

There are 0 best solutions below