<div dir="ltr">Thank you, Richard.  Yeah, the PyCharm config is obviously different, but I did have most of the same PYTHONPATH, PATH, etc. settings in my batch script.  I did more searching, though, and found this gem:<br><br><a href="https://www.gispo.fi/en/blog/cooking-with-gispo-qgis-plugin-development-in-vs-code/">https://www.gispo.fi/en/blog/cooking-with-gispo-qgis-plugin-development-in-vs-code/</a><br><br>In it the author had a critical note (perhaps specifically for VS Code users):<br><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)">Note 1: Currently the only one language server supporting autocompletion for qgis and PyQt5 libraries is the </span><code style="box-sizing:inherit;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:14px;line-height:inherit;font-family:monospace,serif;margin:0px;padding:0px;vertical-align:baseline;color:rgb(255,225,205);letter-spacing:0.7px;background-color:rgb(67,70,98)">Jedi</code><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)"> language server. Qgis and PyQt5 packages are using compiled python code and other language servers are having troubles parsing the API from those libraries (Actually this is for security reasons).</span><br style="box-sizing:inherit;color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)"><br>This solved my problem!  I just assumed that all the language servers were functionally equivalent, so I kept banging my head against a wall trying to get it to work with M$'s recommended Pylance.  So frustrating.<br><br>He subsequently wrote:<br><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)">In the following QGIS releases python stub files that describes the API are included in the </span><code style="box-sizing:inherit;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:14px;line-height:inherit;font-family:monospace,serif;margin:0px;padding:0px;vertical-align:baseline;color:rgb(255,225,205);letter-spacing:0.7px;background-color:rgb(67,70,98)">qgis</code><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)"> package so also much better </span><code style="box-sizing:inherit;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:14px;line-height:inherit;font-family:monospace,serif;margin:0px;padding:0px;vertical-align:baseline;color:rgb(255,225,205);letter-spacing:0.7px;background-color:rgb(67,70,98)">Pylance</code><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)"> language server can be then used. If you have </span><code style="box-sizing:inherit;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:14px;line-height:inherit;font-family:monospace,serif;margin:0px;padding:0px;vertical-align:baseline;color:rgb(255,225,205);letter-spacing:0.7px;background-color:rgb(67,70,98)">*.pyi</code><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)"> files in </span><code style="box-sizing:inherit;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:14px;line-height:inherit;font-family:monospace,serif;margin:0px;padding:0px;vertical-align:baseline;color:rgb(255,225,205);letter-spacing:0.7px;background-color:rgb(67,70,98)">C:/OSGeo4W64/apps/qgis-ltr/python/qgis</code><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)"> go with the </span><code style="box-sizing:inherit;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;font-size:14px;line-height:inherit;font-family:monospace,serif;margin:0px;padding:0px;vertical-align:baseline;color:rgb(255,225,205);letter-spacing:0.7px;background-color:rgb(67,70,98)">Pylance</code><span style="color:rgb(255,225,205);font-family:Inter;font-size:14px;letter-spacing:0.7px;background-color:rgb(67,70,98)"> language server.</span><br><br>I do not see any *.pyi files in my 3.16.9 LTR's C:\OSGeo4W\apps\qgis-ltr\python\qgis dir nor in any of the subdirs.  Should I be?<br><br>In any case, I think this should get me by for a while.  Also, you're definitely right that key info like this needs to go into our centralized PyQGIS developer documentation.<br><br>Cheers!  (And thanks to <a href="mailto:lauri@gispo.fi">lauri@gispo.fi</a> for the blog post!)<br><div>Ari</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 16, 2021 at 1:30 AM Richard Duivenvoorde <<a href="mailto:rdmailings@duif.net">rdmailings@duif.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Ari,<br>
<br>
I'm not using VS Code so sorry, cannot give specific help.<br>
But using Pycharm there also you need to take a lot of hoops to be able to use code-completion.<br>
See for example:<br>
<br>
<a href="https://qtibia.com/how-to-setup-pycharm-for-qgis-development-under-linux-and-windows/" rel="noreferrer" target="_blank">https://qtibia.com/how-to-setup-pycharm-for-qgis-development-under-linux-and-windows/</a><br>
and<br>
<a href="https://silverspringenergy.com/using-pycharm-as-an-ide-for-qgis-3-plugin-development-2/" rel="noreferrer" target="_blank">https://silverspringenergy.com/using-pycharm-as-an-ide-for-qgis-3-plugin-development-2/</a><br>
<br>
The crux is that the editors need to build up some internal structures with all (possible) types and names in it, so paths from libraries (like PyQGIS ones) which are not in the normal python path have to be manually added. AND because pyqgis is actually a wrapper around c++ libs you also have to point to those (I think because else they do not have enough information).<br>
Also with PyCharm it is a lot of fiddling, but in the end it just works.<br>
<br>
IF you manage to make it work: let's write it down somewhere!<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
<br>
On 12/16/21 01:48, Ari Meyer wrote:<br>
> Hi,<br>
> <br>
> We've been trying to use VS Code Python type checkers to reduce errors, and leverage Intellisense for code completion.  We've been unable to get these to work with PyQGIS and PyQT classes, for instance:<br>
> <br>
> image.png<br>
> <br>
> I believe I've traced the problem to some customized importing that's used in places like the following:<br>
> c:\OSGeo4W\apps\qgis-ltr\python\qgis\__init__.py<br>
> c:\OSGeo4W\apps\qgis-ltr\python\qgis\core\__init__.py<br>
> c:\OSGeo4W\apps\qgis-ltr\python\qgis\PyQt\Qt.py<br>
> <br>
> I then found that apparently similar techniques have caused the same types of problems when using libraries like TensorFlow:<br>
> <a href="https://stackoverflow.com/questions/65271399/vs-code-pylance-pylint-cannot-resolve-import" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/65271399/vs-code-pylance-pylint-cannot-resolve-import</a> <<a href="https://stackoverflow.com/questions/65271399/vs-code-pylance-pylint-cannot-resolve-import" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/65271399/vs-code-pylance-pylint-cannot-resolve-import</a>><br>
> <a href="https://github.com/PyCQA/pylint/issues/2603#issuecomment-541622729" rel="noreferrer" target="_blank">https://github.com/PyCQA/pylint/issues/2603#issuecomment-541622729</a> <<a href="https://github.com/PyCQA/pylint/issues/2603#issuecomment-541622729" rel="noreferrer" target="_blank">https://github.com/PyCQA/pylint/issues/2603#issuecomment-541622729</a>><br>
> <br>
> The convoluted ways suggested to deal with these problems aren't really that appealing.  Does anyone have any suggestions for cleaner ways to handle this?<br>
> <br>
> Are there reasons why QGIS has to be implemented like this?  It's not clear from the "monkey patching" comments whether these were temporary workarounds or not.<br>
> <br>
> Thanks,<br>
> Ari<br>
> <br>
> _______________________________________________<br>
> Qgis-user mailing list<br>
> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
<br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div>