我正在尝试为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".这是一个挫折,因为在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发布于 2019-05-03 03:44:55
在OSGeo4W外壳程序中,运行qt5_env.bat和py3_env.bat。然后,将目录更改为
C:\Users\Arnold Kilaini M\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\mmqgis".
运行pyrcc5 -o resources.py resources.qrc
此外,我还找到了一个与您的gis.stackexchange问题相关的link:
希望这能有所帮助!
发布于 2020-06-09 12:38:03
使用这个.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发布于 2021-04-29 04:13:30
对于Ubuntu用户,我尝试了一下,但没有成功:
pb_tool compile同样绑定到安装python-qt5和Ubuntu 20.04找不到它,然后使用
sudo apt install pyqt5-dev-tool然后pb_tool编译,它工作了。
https://stackoverflow.com/questions/55352219
复制相似问题