[英]How to compile the resources.qrc file with pyrcc5
I am trying to make a plugin for QGIS 3(I am using Windows 10) but before it is created one step before it shows this message :我正在尝试为 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".
This is a setback because after setting a plugin path in pyqgis it deploys but the plugin says it cannot find the class module.这是一个挫折,因为在 pyqgis 中设置插件路径后,它会部署,但插件说它找不到类模块。
I have managed to make a plugin but it says error when calling its classFactory()
method thus i think this is because I fail to compile the pyrcc5.我已经设法制作了一个插件,但是在调用它的
classFactory()
方法时它说错误,因此我认为这是因为我未能编译 pyrcc5。
It brings this error upon after selecting it couldn't load plugin 'remove_feature'
due to an error when calling its classFactory()
method :由于调用
classFactory()
方法时出错,选择它无法加载插件'remove_feature'
后会出现此错误:
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
From the OSGeo4W Shell, run qt5_env.bat
and py3_env.bat
.从 OSGeo4W Shell,运行
qt5_env.bat
和py3_env.bat
。 Then, change the directory to然后,将目录更改为
C:\\Users\\Arnold Kilaini M\\AppData\\Roaming\\QGIS\\QGIS3\\profiles\\default\\python\\plugins\\mmqgis".
C:\\Users\\Arnold Kilaini M\\AppData\\Roaming\\QGIS\\QGIS3\\profiles\\default\\python\\plugins\\mmqgis”。
Run pyrcc5 -o resources.py resources.qrc
运行
pyrcc5 -o resources.py resources.qrc
Also, I found the link to a gis.stackexchange question related to yours:另外,我找到了与您相关的 gis.stackexchange 问题的链接:
Hope this helps!希望这可以帮助!
With this .bat I don't have any problem aymore.有了这个 .bat,我再也没有任何问题了。
@echo off
SET QGIS_ROOT=C:\GIS\QGIS
call "%QGIS_ROOT%"\bin\o4w_env.bat
call "%QGIS_ROOT%"\apps\grass\grass78\etc\env.bat
path %PATH%;%QGIS_ROOT%\apps\qgis\bin
path %PATH%;%QGIS_ROOT%\apps\grass\grass78\lib
path %PATH%;C:\GIS\QGIS\apps\Qt5\bin
path %PATH%;C:\GIS\QGIS\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%QGIS_ROOT%\apps\qgis\python
set PYTHONPATH=%PYTHONPATH%;%QGIS_ROOT%\apps\Python37\lib\site-packages
set PYTHONHOME=%QGIS_ROOT%\apps\Python37
set QT_PLUGIN_PATH=%QGIS_ROOT%\apps\qgis\qtplugins;%QGIS_ROOT%\apps\qt5\plugins
set PATH=C:\Program Files\Git\bin;%PATH%
cmd.exe
for Ubuntu users, i tried this and it didn't work out:对于 Ubuntu 用户,我尝试了这个,但没有成功:
pb_tool compile
also tied to install python-qt5 and Ubuntu 20.04 couldn't find it, then used还绑定了安装python-qt5 Ubuntu 20.04 没找到,就用了
sudo apt install pyqt5-dev-tool
then pb_tool compile and it worked.然后 pb_tool 编译并且它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.