PyQt6安装成功但无法导入

发布于 2025-01-20 06:58:58 字数 299 浏览 0 评论 0原文

我使用 pip install pyqt6 下载了 PyQt6,它有很多错误,所以我卸载了它并使用 pip install pyqt6 --user 重新安装,错误消失了。问题是尝试在 VSCODe 或任何其他 ide 中使用它都不起作用。当我写的时候: from PyQt6.QtWidgets import QApplication, QMainWindow, QAction, QMenu, QMessageBox VSCode 给我错误导入“PyQt6.QtWidgets”无法解析。有人可以引导我完成什么吗我可能做错了吗?

I donwloaded PyQt6 using pip install pyqt6 and it had a bunch of errors so I uninstalled it and reinstalled it with pip install pyqt6 --user and the errors dissappeared. problem is trying to use it in VSCODe or any other ide doesn't work. When i write:
from PyQt6.QtWidgets import QApplication, QMainWindow, QAction, QMenu, QMessageBox VSCode gives me the error Import "PyQt6.QtWidgets" could not be resolved. Could someone walk me through what I may of done wrong please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉城メ夜风 2025-01-27 06:58:58

在 VSCode 中尝试此操作:

  • 在 VSCode 窗口的右下角,您应该会看到语言
    VSCode 当前使用的模式和版本。类似于“Python”3.10.7
  • 如果您将鼠标悬停在此文本上(例如 3.10.7),VSCODE 将显示
    该版本使用的实际路径。
  • 如果您单击版本,则可以在编辑(并执行) Python 代码。语言和版本反映了所使用的库的路径。
  • 就我而言,当我查看时,该版本已更改为我之前错误安装的测试版(3.11.03b)。我安装PyQT6时使用的版本是3.10.7。
  • 当我将版本改回 3.10.7 时,突然一切又恢复正常了。

就我而言,我一直在从 PyQT5 迁移到 PyQT6 的过程中移动内容,现在为迁移的代码使用不同的文件夹。我打开了一个新的 VSCode 窗口,然后打开了新的 PyQT6 文件夹,但我没有注意到 VSCode 选择了它认为的“最新”版本的解释器。

Try this in VSCode:

  • On the lower right of the VSCode window you should see the language
    mode and version that VSCode is currently using. Something like "Python" 3.10.7.
  • If you HOVER over this text (like 3.10.7), VSCODE will display the
    actual path used for that version.
  • If you CLICK on the version, you can change the LANGUAGE MODE and VERSION that is being used by VSCode in the window while editing (and executing) Python code. The language and version reflect the path to the library used.
  • In my case when I looked, the version had changed to a beta version I'd mistakingly installed earlier (3.11.03b). The version I was using when I installed PyQT6 was 3.10.7.
  • When I changed the version back to 3.10.7, suddenly everything worked again.

In my case, I had been moving things around in migrating from PyQT5 to PyQT6 and was now using a different file folder for my migrated code. I opened up a new VSCode Window and then my new PyQT6 folder, and I failed to notice that VSCode had chosen what it thought was the 'latest' version of the interpreter.

猥︴琐丶欲为 2025-01-27 06:58:58

在终端中尝试PIP列表,以查看是否显示为安装。如果它确实显示为已安装,但仍无法使用双检查以确保VSCODE使用正确的解释器。按 ctrl + shift + p 然后键入python:select Instrymer,请确保选择正确的一个。

Try pip list in a terminal to see if it shows up as installed. If it does show up as installed but still doesn't work double check to make sure VSCode is using the correct interpreter. Press Ctrl + shift + P then type in python: select interpreter, make sure the correct one is selected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文