0

This is a straightforward question but I've been looking for a solution for such a long time. The document "IDE Settings for Developing QGIS" says: 'on Windows you need to make sure you that you have the same environment settings and use the same libraries and interpreter as QGIS.'

How can I use another Python interpreter (e.g the one in some Python distributions such as Winpython) with the QGIS environment settings (I almost know how to do that by using batch files to set the correct environment settings) and then how can I use the QGIS essential libraries?

I'm asking this for the Windows operating system. If anyone has any idea on how to do it for QGIS 3.x that is much more preferred.

2
  • It's better to install the osgeo4w version and see : gis.stackexchange.com/questions/273870/…. Commented Sep 30, 2019 at 11:58
  • @J.Monticolo Yes, I'm familiar with that procedure (py3-env) and I'm using OsGeo4w64. could you please provide an answer about how to use different python than the built-in one?
    – Ash
    Commented Sep 30, 2019 at 12:09

1 Answer 1

0

I found the answer but it's really costly to do that. When you want to use another Python interpreter you must not call o4w_env.bat since it calls many .bat files in advance which you don't want. You will only need relevant DLL and libraries from QGIS, and nothing more.

Based on this, you need to add those relevant directories to your PATH in a batch file. So:

path %PATH%;%OSGEO4W_ROOT%\apps\qgis-ltr\bin
path %PATH%;C:\OSGeo4W64\apps\Qt5\bin
path %PATH%;C:\OSGeo4W64\apps\Python37\Scripts
path %PATH%;OSGEO4W_ROOT\apps\qgis-ltr\python\plugins

Then set your desired PYTHONPATH and PYTHONHOME. And start your preferred IDE. Add these path in the IDE's preferences too. This will provide auto-completion possibilities.

Attention:

You will need to pay attention to the dependencies which will be very complicated. So regular crashes are common. Actually, it's not wise to do it unless you really need to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.