简体   繁体   English

PyCharm 错误 - 没有名为“sip”的模块(PyQt4)

[英]PyCharm error - No module named 'sip' (PyQt4)

OK, so I need to make a project in PyQt, and I'm using PyQt4 since I found more tutorials on this and it is easier for me.好的,所以我需要在 PyQt 中创建一个项目,并且我正在使用 PyQt4,因为我找到了更多关于此的教程,这对我来说更容易。 I installed PyCharm as my IDE.我安装了 PyCharm 作为我的 IDE。 I haven't had any python compilers so I installed Python 3.7.5 (from Microsoft Store since PyCharm recommended that), and configured the interpreter in PyCharm (so now, python works)我没有任何 python 编译器,所以我安装了 Python 3.7.5(从 PyCharm 推荐的 Microsoft Store),并在 PyCharm 中配置了解释器(所以现在,python 工作)

Then, I needed to install PyQt4, and since it didn't work from PyCharm's project interpreter -> install package, I downloaded "PyQt4-4.11.4-cp37-cp37m-win_amd64" and installed it with pip.然后,我需要安装 PyQt4,由于它在 PyCharm 的项目解释器 -> 安装包中不起作用,我下载了“PyQt4-4.11.4-cp37-cp37m-win_amd64”并用 pip 安装它。
Then, I installed sip also with pip.然后,我也用 pip 安装了 sip。 The thing is that I get an error in my code in PyCharm.问题是我在 PyCharm 中的代码中出现错误。
from PyQt4 import QtGui
ModuleNotFoundError: No module named 'sip'

I also configured all my Windows PATHs, when I installed sip it gave me an error saying that the path isn't added.我还配置了我所有的 Windows PATH,当我安装 sip 时,它给了我一个错误,说没有添加路径。 I added that path.我添加了那个路径。 I also added the pyqt4 path.我还添加了 pyqt4 路径。 These are my paths:这些是我的路径:

C:\\Users\\b997a\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sipbuild C:\\Users\\b997a\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sipbuild

C:\\Users\\b997a\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages C:\\Users\\b997a\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages

'C:\\Users\\b997a\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\Scripts 'C:\\Users\\b997a\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\Scripts

And these are all the packages I think I have installed in PyCharm:这些是我认为我已经在 PyCharm 中安装的所有软件包: 这是我认为我在 PyCharm 中安装的所有软件包

Do you know what I can do?你知道我能做什么吗? I really don't want to use PyQt5 since I know a found tutorials on exactly what I want to do on PyQt4 and I don't really have time to learn PyQt5 now...我真的不想使用 PyQt5,因为我知道找到了关于我想在 PyQt4 上做什么的教程,而且我现在真的没有时间学习 PyQt5...

I also tried to see if Python 3.7.5 Shell (IDLE) will raise an error, and yes, it did.我还尝试查看 Python 3.7.5 Shell (IDLE) 是否会引发错误,是的,确实如此。 I have the same error in Python's IDLE.我在 Python 的 IDLE 中也有同样的错误。

What is the problem?问题是什么? It worked for a while until I deleted Python a few weeks ago, but now it doesn't work anymore.它工作了一段时间,直到几周前我删除了 Python,但现在它不再工作了。

Thanks a lot!非常感谢!

I have recently faced such issues, so my recommendations are:我最近遇到了这样的问题,所以我的建议是:

  1. It's good to activate your virtual env for your project.为您的项目激活虚拟环境很好。
  2. Usually pip should install the required binaries, but if it doesn't, try searching the same from pycharm -> settings and add directly from there.通常 pip 应该安装所需的二进制文件,但如果没有,请尝试从 pycharm -> settings 中搜索相同的文件并直接从那里添加。 This has always worked for me.这一直对我有用。

PS I was not able to add comment, so I posted it as answer. PS我无法添加评论,所以我将其发布为答案。

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

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