[Qgis-developer] PyQGIS API code completion not working in PyCharm

Larry Shaffer larrys at dakotacarto.com
Wed Oct 9 08:44:26 PDT 2013


Hi Jorge,

On Wed, Oct 9, 2013 at 5:44 AM, Jorge Gil <jorge.gil at ucl.ac.uk> wrote:

> Hi everyone,
>
> I'm new to QGIS plug-in developemtn and I'm setting up a development
> environment on Mac OS X.
>
> At the moment I'm going with PyCharm and got the remote debugging to work.
> Thanks to this list!
>

Welcome to developing with QGIS. PyCharm is an excellent choice for IDE,
especially now that 3.0 has a free community version and more support for
PyQt.


> One thing I can't get to work is code completion for the PyQGIS API.
>
> I've added '/Applications/QGIS.app/**Contents/Resources/python/**qgis/'
> and '/Applications/QGIS.app/**Contents/Resources/python/' to the
> interpreter's path. PyCharm can find PyQGIS and ads it to the external
> libraries. This way I can import the qgis modules without errors, in the
> Python console for example.
> However, code completion doesn't work in the editor nor in the console.
>

You only need the '/Applications/QGIS.app/Contents/Resources/python' path
added (assuming you are using a Kyngchaos.com QGIS install), so I recommend
removing the other path . However, I have noticed that sometimes PyCharm on
Mac does not properly rebuild the 'skeletons' for code completion (I'm
using PyCharm 2.7.3). Try relaunching the app and removing/re-adding the
path, then clicking the reload button. You should see a progress bar and
eventually notice the qgis.* modules being parsed. If not there may be an
issue.

For plugin development, I add external commands, several of which are for
running my plugin's Makefile [0]. While the new PyCharm 3.0 has an embedded
terminal, I find assigning a key shortcut (say Ctrl-M) to the make <prompt>
command to be very quick for deploying the plugin to
~/.qgis2/python/plugins/. Deploying is the best-practice means of testing
your plugin, instead of symlinking it, but that also works.

Also, I recommend using the Plugin Reloader PyQGIS plugin to reload your
plugin within QGIS, so you do not have to relaunch QGIS every time you
propagate a change in your plugin.

[0] http://drive.dakotacarto.com/qgis/pycharm-ext-cmd_make.png

Regards,

Larry

Thanks in advance for your help,
> Jorge
>
>
> ______________________________**_________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/qgis-**developer<http://lists.osgeo.org/mailman/listinfo/qgis-developer>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131009/9593a670/attachment.html>


More information about the Qgis-developer mailing list