2

Note: My first attempt at asking a question was confusing PyQt and pyqt_fit. I've preserved my first attempt below for archival purposes. It seems clear that PyQt should be a prerequisite to getting pyqt_fit working.

I installed PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe, available here. I see pyqt-4.10.4-py27_1.tar in \Anaconda\pkgs, and if I run the installer again, it tells me it's installed.

Unfortunately, it seems that iPython still isn't finding it:

In [5]: from PyQt4 import QtCore, QtGui
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-5a7197379ef6> in <module>()
----> 1 from PyQt4 import QtCore, QtGui

ImportError: No module named PyQt4

How can I troubleshoot why it's not finding this?

System specs

  • Python 2.7.9 :: Anaconda 2.2.0 (64-bit)
  • OS Name: Microsoft Windows 8.1
  • OS Version: 6.3.9600 N/A Build 9600
  • OS Configuration: Standalone Workstation
  • OS Build Type: Multiprocessor Free
  • System Manufacturer: Dell Inc.
  • System Model: Inspiron 5547


First attempt at question

I installed PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe, available here, in the understanding that it would give me "everything needed for PyQt4 development except for Python itself." Instead, though, I'm finding that importing pyqt_fit and pyqt_fit1d is giving me errors seemingly related to compilation.

Summary

  • I'm trying to import these through the iPython prompt and iPython Notebook, and I have a hunch they're looking at somewhat different instances of pyqt*, but I don't know how to confirm this intuition.

  • When I tried to import pyqt_fit or pyqt_fit1d, I got a "DistutilsPlatformError: Unable to find vcvarsall.bat". I installed the Microsoft Visual C++ Compiler for Python 2.7, and hacked the registry a bit to get it to not complain about not finding vcvarsall.bat, but the compilation still fails.

It seems like working at the compiler level shouldn't be necessary if the installer worked. What am I not understanding?

Observed behavior from an iPython prompt

  • Typing "import pyqt[Tab]" suggests only pyqt_fit1d and pyqtconfig.

  • import pyqtconfig fails with ImportError: No module named sipconfig. (I believe this used to work only at the iPython prompt before I installed the VC++ stuff.)

  • import pyqt_fit1d fails the first time with ImportError: Building module pyqt_fit._kernels failed: ["CompileError: command 'C:\\\\Users\\\\<username>\\\\AppData\\\\Local\\\\Programs\\\\Common\\\Microsoft\\\\Visual C++ for Python\\\\9.0\\\\VC\\\\Bin\\\\amd64\\\\cl.exe' failed with exit status 2\n"]. Complete backtrace here.

  • On subsequent attempts, it fails with ImportError: cannot import name functions in C:\Anaconda\lib\site-packages\pyqt_fit__init__.py.

  • import pyqt_fit behaves exactly the same.

Observed behavior from an iPython notebook

  • Typing "import pyqt[Tab]" in a new notebook suggests only pyqtconfig.

  • import pyqtconfig gets ImportError: No module named sipconfig, as at iPython prompt.

  • import pyqt_fit1d fails with ImportError: No module named pyqt_fit1d -- Note difference from iPython prompt above
  • import pyqt_fit fails with the same ```ImportError: Building module pyqt_fit._kernels failed: ["CompileError: command 'C:\\Users\\\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2\n"]
Philip
  • 323
  • 3
  • 13
  • Do you see a PyQt4 folder in Anaconda\Lib\site-packages? (I assume you aren't using anaconda's built in environment switcher?) – three_pineapples Sep 02 '15 at 02:22
  • Realized I could rerun the installer despite the warning, so I did, and it seems to import PyQt4 now. (Not using Ananconda env switcher.) – Philip Sep 02 '15 at 17:55
  • However, when the installer offers to uninstall, that seems to be a total red herring. If I uncheck every box (except "Extension modules", which is disabled) it appears to only be installing stuff. If I run the installer again, I get the same message about it being installed. For future reference, how do I uninstall it? – Philip Sep 02 '15 at 17:59

2 Answers2

1

pyqt_fit appears to be a completely separate package, not maintained by the PyQt developers.

To use PyQt4, you want to try from PyQt4 import QtCore, QtGui. I suspect the auto-completion of your python terminal just doesn't know about the PyQt package you installed.

three_pineapples
  • 11,579
  • 5
  • 38
  • 75
  • Oops, that's embarrassing to forget about the distinction between the two. So the root problem is, despite installation, PyQt doesn't appear to work at all:```ImportError: No module named PyQt4``` Should I edit my initial question? AFAIK pyqt_fit shouldn't ever work until PyQt4 (or 5) works. – Philip Sep 01 '15 at 22:22
0

If you want to install PyQt4, you can do so using anaconda.
1. Go to Anaconda-> Environments
2. You will get a list of modules already installed. Type PyQt in search bar of variables windows
3. Select Not Installed from the drop down
4. From the list, click on anyqt and pyqtgraph
5. Click Apply

It will automatically install PyQt and you won't get this error: ImportError: No module named PyQt4

Navneet
  • 71
  • 8