PyQt6安装成功但无法导入
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 VSCode 中尝试此操作:
VSCode 当前使用的模式和版本。类似于“Python”3.10.7。
该版本使用的实际路径。
就我而言,我一直在从 PyQT5 迁移到 PyQT6 的过程中移动内容,现在为迁移的代码使用不同的文件夹。我打开了一个新的 VSCode 窗口,然后打开了新的 PyQT6 文件夹,但我没有注意到 VSCode 选择了它认为的“最新”版本的解释器。
Try this in VSCode:
mode and version that VSCode is currently using. Something like "Python" 3.10.7.
actual path used for that version.
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.
在终端中尝试
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 inpython: select interpreter
, make sure the correct one is selected.