<div dir="ltr">Hi,<div>that looks like an interesting workaround! What are the pitfalls? Don't you need to see the real python code when developing? </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 11, 2017 at 1:55 PM, Arnaud Morvan <span dir="ltr"><<a href="mailto:arnaud.morvan@camptocamp.com" target="_blank">arnaud.morvan@camptocamp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hello Michal,
<br>
<br>
I've also had this error some times ago, I do not remember if I
succeed with pyuic4, nor the solution.<br>
<br>
But IMHO it is simpler to load "ui" files at runtime.<br>
Here is an example from "processing" plugin :<br>
<br>
import os<br>
from qgis.PyQt import uic<br>
<br>
pluginPath = os.path.split(os.path.dirname(<wbr>__file__))[0]<br>
WIDGET, BASE = uic.loadUiType(<br>
os.path.join(pluginPath, 'ui', 'DlgConfig.ui'))<br>
<br>
class ConfigDialog(BASE, WIDGET):<br>
<br>
<br>
=> no need to run make or similar to create python files each
time you change something in your ui files.<br>
<br>
load the plugin from the source folder (create a symbolic link from
home QGIS plugins dir to plugin source dir)<br>
change something in the ui file<br>
reload the plugin using "plugin reloader" and you immediately see
the result in QGIS.<br>
<br>
Regards
<pre class="m_-2501770787831927990moz-signature" cols="72">Arnaud Morvan
Ingénieur logiciel
Tél: <a href="tel:+33%204%2058%2048%2020%2032" value="+33458482032" target="_blank">+33 (0)4 58 48 20 32</a>
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
<a class="m_-2501770787831927990moz-txt-link-freetext" href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a></pre><div><div class="h5">
<div class="m_-2501770787831927990moz-cite-prefix">Le 11/05/2017 à 12:44, Michal
Zimmermann a écrit :<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">Hi,
<div>I'm starting with qgis plugin development on ubuntu-based
Mint OS (v 18.1 Serena). I created a very simple form in Qt
Designer 4.8.7 and tried to convert it to python file with <br>
<div>
<div><br>
</div>
<div>pyuic4 -d form.ui -o form.py<br>
</div>
<div><br>
</div>
<div>This results in </div>
<div><br>
</div>
<div>
<div>Traceback (most recent call last):</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/PyQt4/uic/port_v2/<wbr>invoke.py",
line 34, in invoke</div>
<div> exit_status = driver.invoke()</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/PyQt4/uic/driver.py",
line 59, in invoke</div>
<div> self._generate()</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/PyQt4/uic/driver.py",
line 98, in _generate</div>
<div> self._opts.resource_suffix)</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/PyQt4/uic/__init__.<wbr>py",
line 173, in compileUi</div>
<div> winfo = compiler.UICompiler().<wbr>compileUi(uifile,
pyfile, from_imports, resource_suffix)</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/PyQt4/uic/Compiler/<wbr>compiler.py",
line 55, in __init__</div>
<div> CompilerCreatorPolicy())</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/PyQt4/uic/uiparser.<wbr>py",
line 170, in __init__</div>
<div> self.factory = QObjectCreator(creatorPolicy)</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/PyQt4/uic/objcreator.<wbr>py",
line 94, in __init__</div>
<div> modinfo = plugin_locals["<wbr>moduleInformation"]()</div>
<div> File "<string>", line 52, in
moduleInformation</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/qgis/__init__.py",
line 26, in <module></div>
<div> from qgis.PyQt import QtCore</div>
<div> File
"/usr/lib/python2.7/dist-<wbr>packages/qgis/PyQt/QtCore.py",
line 28, in <module></div>
<div> sip.setapi(api, 2)</div>
<div>ValueError: API 'QDate' has already been set to
version 1</div>
</div>
<div><br>
</div>
<div>If I
change /usr/lib/python2.7/<wbr>dist-packages/qgis/PyQt/<wbr>QtCore.py
line 28 to sip.setapi(api, 1), it works, QGIS starts with
a following message though:</div>
<div><br>
</div>
<div>
<p style="margin:0px"><span style="color:rgb(255,0,0)">Couldn't
load PyQGIS.<br>
Python support will be disabled.</span><br>
</p>
<pre style="margin-top:12px;margin-bottom:12px"><span style="font-family:"courier new,courier"">
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/dist-<wbr>packages/qgis/__init__.py", line 26, in
from qgis.PyQt import QtCore
File "/usr/lib/python2.7/dist-<wbr>packages/qgis/PyQt/QtCore.py", line 28, in
sip.setapi(api, 1)
ValueError: API 'QDate' has already been set to version 2
</span></pre>
<p style="margin:0px">Python version:<br>
2.7.12 (default, Nov 19 2016, 06:48:10) <br>
[GCC 5.4.0 20160609]<br>
<br>
QGIS version:<br>
2.18.7 'Las Palmas', 3b30e6a</p>
</div>
<div><br>
</div>
<div>What exactly do I have to do to make the both sides
work?</div>
<div><br>
</div>
-- <br>
<div class="m_-2501770787831927990gmail_signature">
<div dir="ltr">
<div>Michal Zimmermann (zimmi) <br>
WWW: <a href="https://www.zimmi.cz" target="_blank">https://www.zimmi.cz</a></div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="m_-2501770787831927990mimeAttachmentHeader"></fieldset>
<br>
</div></div><pre>______________________________<wbr>_________________
QGIS-Developer mailing list
<a class="m_-2501770787831927990moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="m_-2501770787831927990moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a>
Unsubscribe: <a class="m_-2501770787831927990moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a></pre>
</blockquote>
<br>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Michal Zimmermann (zimmi) <br>WWW: <a href="https://www.zimmi.cz" target="_blank">https://www.zimmi.cz</a></div></div></div>
</div>