如何用pyrcc5编译resources.qrc文件

Kil*_*eki 6 python plugins

我正在尝试为 QGIS 3(我使用的是 Windows 10)制作一个插件,但在它显示此消息之前的一步创建之前:

"The resource compiler pyrcc5 was not found in your path. You'll have to manually compile the resources .qrc file with pyrcc5 before installing your plugin".
Run Code Online (Sandbox Code Playgroud)

这是一个挫折,因为在 pyqgis 中设置插件路径后,它会部署,但插件说它找不到类模块。

我已经设法制作了一个插件,但是在调用它的classFactory()方法时它说错误,因此我认为这是因为我未能编译 pyrcc5。

'remove_feature'由于调用其classFactory()方法时出错,选择它无法加载插件后会出现此错误:

ModuleNotFoundError: No module named 'remove_feature.resources' 
Traceback (most recent call last):
  File "C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 335, in startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\remove_feature\__init__.py", line 35, in classFactory
    from .Remove_feature import Remove_feature
  File "C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\remove_feature\Remove_feature.py", line 29, in 
    from .resources import *
  File "C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'remove_feature.resources'

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] 
QGIS version: 3.4.5-Madeira Madeira, 89ee6f6e23 

Python Path:
C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python
C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python/plugins
C:\Program Files\QGIS 3.4\bin\python37.zip
C:\PROGRA~1\QGIS3~1.4\apps\Python37\DLLs
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib
C:\Program Files\QGIS 3.4\bin
C:\PROGRA~1\QGIS3~1.4\apps\Python37
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\win32
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\Pythonwin
C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\Arnold Kilaini M\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\mmqgis/forms
Run Code Online (Sandbox Code Playgroud)

小智 9

在 OSGeo4W Shell 中,运行qt5_env.batpy3_env.bat. 然后,将目录更改为

C:\Users\Arnold Kilaini M\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\mmqgis”。

pyrcc5 -o resources.py resources.qrc

另外,我找到了与您相关的 gis.stackexchange 问题的链接

希望这可以帮助!