问题描述
运行QGis 3.14.16我想打开一个使用protobuf的个人插件。 在Windows下,我具有protobuf == 3.13.0并且可以工作。 在Linux下,它没有说插件需要3.13.0,而QGis有3.0.0。
然后如何为QGis安装protobuf 3.0.0?
我在Python控制台中尝试过:
use ndarray::{Axis,Array}; // 0.13.1
use rand::seq::SliceRandom; // 0.7.3
use std::iter::FromIterator;
fn main() {
let array = Array::from_iter(0..15).into_shape((5,3)).unwrap();
println!("Before shuffling rows:\n{}",array);
let mut permutation: Vec<usize> = (0..array.nrows()).collect();
permutation.shuffle(&mut rand::thread_rng());
for i in permutation.iter() {
let row = array.index_axis(Axis(0),*i);
println!("Row number {} is {}!",i,row);
}
}
,它显示import pkg_resources
installed_packages = pkg_resources.working_set
installed_packages_list = sorted(["%s==%s" % (i.key,i.version) for i in installed_packages])
print(installed_packages_list)
。奇怪。
我尝试过
protobuf==3.13.0
但是我仍然得到QGis找到3.0.0的消息窗口。
还是有一种方法可以将python虚拟环境用于QGis?
您可以通过在新目录protobuf_tester中创建三个文件轻松地将其检出
import pip
pip.main(["install","protobuf==3.13.0"])
- Windows: C:\Users\USERNAME\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\protobuf_tester
- Linux: /lhome/USERNAME/.local/share/QGIS/QGIS3/profiles/default/python/plugins/protobuf_tester
__init__.py
# -*- coding: utf-8 -*-
from .protobuf_tester import ProtobufTester
def classFactory(iface):
return ProtobufTester(iface)
Metadata.txt
# This file contains Metadata for your plugin. Since
# version 2.0 of QGIS this is the proper way to supply
# @R_393_4045@ion about a plugin. The old method of
# embedding Metadata in __init__.py will
# is no longer supported since version 2.0.
# This file should be included when you package your plugin.# Mandatory items:
[general]
name=ProtobufTester
qgisMinimumVersion=3.0
description=Tries to import the protobuf modules
version=0.1
author=Roland
about=Since it prints results to the python console,please open the python console first via the extension menu. In case of an google protobuf-error you'll get a message window,in case of success you don't.
# Tags are comma separated with spaces allowed
tags=python,protobuf,qgis
experimental=True
# deprecated flag (applies to the whole plugin,not just a single version)
deprecated=False
protobuf_tester.py
要进行测试,请运行QGis,然后通过扩展菜单打开python控制台 并在ProtobufTester条目下启动两个菜单点。
如果您像我一样遇到错误(发现protobuf 3.0.0但需要3.13.0) 我该怎么解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)