简体   繁体   English

PyCharm无法解析对PyQT5模块的引用

[英]PyCharm can't resolve references to PyQT5 modules

I'm trying to learn how to use PyQT5. 我正在尝试学习如何使用PyQT5。 I created a new folder under my user profile and spun up a virtualenv (and installed PyQT5 from pip3) in a folder called env . 我在我的用户配置文件下创建了一个新文件夹,并在一个名为env的文件夹中创建了一个virtualenv(并从pip3安装了PyQT5)。 I created the project in another folder called guis and pointed PyCharm to the env environment. 我在另一个名为guis文件夹中创建了该项目,并将PyCharm指向了env环境。 Pycharm can't find the submodules but sees PyQT5.QtWidgets just fine. Pycharm找不到子模块,但看到PyQT5.QtWidgets就好了。

Screnshot: Screnshot: 在此输入图像描述

I got it to work by removing PyQT5 from 我通过删除PyQT5来实现它

Settings > Project > Project Interpreter

and reinstalling it within PyCharm . 在PyCharm中重新安装它。

Restart PyCharm afterwards. 之后重启PyCharm。

我不得不去File --> Invalidate Caches / Restart

In my case i had non-latin symbols in path to python (in AppData). 在我的情况下,我在python的路径中有非拉丁符号(在AppData中)。 I made new windows user with only-latin name, using it instead of original user fixed the problem. 我使用只有拉丁名称的新窗户用户,使用它而不是原始用户修复了问题。

setting -> project interpreter -> click setting icon -> add -> new environment -> ( add path) -> check 'inherit global site-packages' and 'make available to all projects' -> click OK 设置 - >项目解释器 - >单击设置图标 - >添加 - >新环境 - >(添加路径) - >选中'继承全局站点包'和'使所有项目可用' - >单击确定

always use same environment or you can use different environment for different projects, just check global packages 总是使用相同的环境,或者您可以为不同的项目使用不同的环境,只需检查全局包

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

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