简体   繁体   English

带有 Anaconda Python 的 PyQt Windows 安装程序——未找到 PyQt4; 我该如何排除故障?

[英]PyQt Windows installer with Anaconda Python--PyQt4 not found; how do I troubleshoot?

Note: My first attempt at asking a question was confusing PyQt and pyqt_fit.注意:我第一次尝试提问时混淆了 PyQt 和 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.很明显,PyQt 应该是让 pyqt_fit 工作的先决条件。

I installed PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe, available here .我安装了 PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe,可在此处获得 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.我在\\Anaconda\\pkgs 中看到pyqt-4.10.4-py27_1.tar,如果我再次运行安装程序,它会告诉我它已安装。

Unfortunately, it seems that iPython still isn't finding it:不幸的是,似乎 iPython 仍然没有找到它:

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) Python 2.7.9 :: Anaconda 2.2.0(64 位)
  • OS Name: Microsoft Windows 8.1操作系统名称:Microsoft Windows 8.1
  • OS Version: 6.3.9600 N/A Build 9600操作系统版本:6.3.9600 不适用 Build 9600
  • OS Configuration: Standalone Workstation操作系统配置:独立工作站
  • OS Build Type: Multiprocessor Free操作系统构建类型:多处理器免费
  • System Manufacturer: Dell Inc.系统制造商:戴尔公司
  • System Model: Inspiron 5547系统型号: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."我安装了 PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe,可在此处获得,因为它会为我提供“除了 Python 本身之外的 PyQt4 开发所需的一切”。 Instead, though, I'm finding that importing pyqt_fit and pyqt_fit1d is giving me errors seemingly related to compilation.但是,相反,我发现导入 pyqt_fit 和 pyqt_fit1d 给我的错误似乎与编译有关。

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.我正在尝试通过 iPython 提示符和 iPython Notebook 导入这些,我有一种预感,他们正在查看 pyqt* 的一些不同实例,但我不知道如何确认这种直觉。

  • When I tried to import pyqt_fit or pyqt_fit1d, I got a "DistutilsPlatformError: Unable to find vcvarsall.bat".当我尝试导入 pyqt_fit 或 pyqt_fit1d 时,出现“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.为 Python 2.7安装了Microsoft Visual C++ 编译器,并稍微修改了注册表以使其不抱怨找不到 vcvarsall.bat,但编译仍然失败。

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从 iPython 提示观察到的行为

  • Typing "import pyqt[Tab]" suggests only pyqt_fit1d and pyqtconfig.键入“import pyqt[Tab]”仅建议使用 pyqt_fit1d 和 pyqtconfig。

  • import pyqtconfig fails with ImportError: No module named sipconfig . import pyqtconfig失败并显示ImportError: No module named sipconfig (I believe this used to work only at the iPython prompt before I installed the VC++ stuff.) (我相信在我安装 VC++ 之前,这只能在 iPython 提示符下工作。)

  • 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"] . import pyqt_fit1d第一次失败,出现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.在随后的尝试中,它失败并显示ImportError: cannot import name functions in C:\\Anaconda\\lib\\site-packages\\pyqt_fit__init__.py。

  • import pyqt_fit behaves exactly the same. import pyqt_fit行为完全相同。

Observed behavior from an iPython notebook从 iPython 笔记本观察到的行为

  • Typing "import pyqt[Tab]" in a new notebook suggests only pyqtconfig.在新笔记本中键入“import pyqt[Tab]”仅建议使用 pyqtconfig。

  • import pyqtconfig gets ImportError: No module named sipconfig , as at iPython prompt. import pyqtconfig获取ImportError: No module named sipconfig ,就像在 iPython 提示符下一样。

  • import pyqt_fit1d fails with ImportError: No module named pyqt_fit1d -- Note difference from iPython prompt above import pyqt_fit1d失败并显示ImportError: No module named pyqt_fit1d --注意与上面 iPython 提示的区别
  • 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"] import pyqt_fit失败并显示相同的 ```ImportError: Building module pyqt_fit._kernels failed: ["CompileError: command 'C:\\\\Users\\\\\\\\AppData\\\\Local\\\\Programs\\\\Common\\\\Microsoft\\\\Visual C++对于 Python\\\\9.0\\\\VC\\\\Bin\\\\amd64\\\\cl.exe' 失败,退出状态为 2\\n"]

pyqt_fit appears to be a completely separate package, not maintained by the PyQt developers. pyqt_fit似乎是一个完全独立的包,不是由 PyQt 开发人员维护的。

To use PyQt4, you want to try from PyQt4 import QtCore, QtGui .要使用 PyQt4,您想尝试from PyQt4 import QtCore, QtGui I suspect the auto-completion of your python terminal just doesn't know about the PyQt package you installed.我怀疑你的 python 终端的自动完成不知道你安装的 PyQt 包。

If you want to install PyQt4 , you can do so using anaconda.如果你想安装PyQt4 ,你可以使用 anaconda 来安装。
1. Go to Anaconda-> Environments 1. 前往Anaconda-> Environments
2. You will get a list of modules already installed. 2. 您将获得已安装模块的列表。 Type PyQt in search bar of variables windows在变量窗口的搜索栏中输入PyQt
3. Select Not Installed from the drop down 3. 从下拉菜单中选择未安装
4. From the list, click on anyqt and pyqtgraph 4.从列表中,点击anyqtpyqtgraph
5. Click Apply 5. 单击Apply

It will automatically install PyQt and you won't get this error: ImportError: No module named PyQt4它会自动安装 PyQt,你不会得到这个错误: ImportError: No module named PyQt4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM