[Qgis-user] How to set PyQGIS imported in VS Code in Windows for a Python file?

PIERRE Sylvain sylvain.pierre at alsace.eu
Mon Mar 13 01:02:53 PDT 2023


Oops ! it’s in .env file and it looks like this for me :

PATH=$PATH;"C:\Program Files\QGIS 3.16.16\bin\";"C:\Program Files\QGIS 3.16.16\apps\qgis\bin"
PYTHONPATH="C:\Program Files\QGIS 3.16.16\apps\qgis\python"
PYTHON_VERSION=Python39

[cid:image001.jpg at 01D9558A.97F7D670]
Sylvain PIERRE
Chef de projet système d’information
Direction des Systèmes d’Information et du Développement Numérique
Service Projets et Ingénierie Numérique
Collectivité européenne d’Alsace
Tél : 03 88 76 68 88
sylvain.pierre at alsace.eu<mailto:sylvain.pierre at alsace.eu>
www.alsace.eu<http://www.alsace.eu>
[facebook]<http://www.facebook.com/toutelalsace> [twitter] <http://www.twitter.com/toutelalsace>  [insta] <http://www.instagram.com/toutelalsace>

De : QGIS-User <qgis-user-bounces at lists.osgeo.org> De la part de PIERRE Sylvain via QGIS-User
Envoyé : lundi 13 mars 2023 08:56
À : LI, Xin Stephen [MIT] <stephenli at eduhk.hk>
Cc : qgis-user at lists.osgeo.org
Objet : Re: [Qgis-user] How to set PyQGIS imported in VS Code in Windows for a Python file?

Soyez vigilant : ce courriel provient d'une organisation externe à la CeA.
• Assurez-vous d’abord qu’il ne s’agit pas d’un email malveillant avant de cliquer sur tout lien ou pièce jointe.
Apprendre à reconnaître un email de phishing.<https://intranet.alsace.eu/actualites/apprenez-a-reconnaitre-un-email-phishing/>
Hi,

Did you set these variable in env file in your user .vscode dir ?


De : QGIS-User <qgis-user-bounces at lists.osgeo.org<mailto:qgis-user-bounces at lists.osgeo.org>> De la part de LI, Xin Stephen [MIT] via QGIS-User
Envoyé : lundi 13 mars 2023 07:30
À : qgis-user at lists.osgeo.org<mailto:qgis-user at lists.osgeo.org>
Objet : [Qgis-user] How to set PyQGIS imported in VS Code in Windows for a Python file?

Soyez vigilant : ce courriel provient d'une organisation externe à la CeA.
• Assurez-vous d’abord qu’il ne s’agit pas d’un email malveillant avant de cliquer sur tout lien ou pièce jointe.
Apprendre à reconnaître un email de phishing.<https://intranet.alsace.eu/actualites/apprenez-a-reconnaitre-un-email-phishing/>
The OS is Windows 10,
The QGIS version is 3.28 LTR
The Python version is 3.11

The steps following the steps in stection 1.4.1 for the PyQGIS Cookbook (GQIS Testing), i.e. https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html#python-applications
The “PAHT” and “PYTHONPYTHON” have been added.

The problem is:
When  running the Python program file with “import qgis.core”, there is the error
“ModuleNotFoundError: No module named 'qgis' ”

Moreover, after reinstalling the Python 3.9.5 as the QGIS related, then run the Python file in VS Code by Python 3.9.5, the Error is the same.

Any suggestions could help modify this setting?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230313/4b3eb30b/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 8103 bytes
Desc: image001.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230313/4b3eb30b/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 827 bytes
Desc: image002.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230313/4b3eb30b/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 853 bytes
Desc: image003.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230313/4b3eb30b/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 1038 bytes
Desc: image004.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230313/4b3eb30b/attachment-0005.png>


More information about the QGIS-User mailing list