Question

Running PyQGIS in FME PythonCaller transformer?

  • 13 September 2018
  • 7 replies
  • 37 views

Badge

I am trying to get information from a QGIS project and layers and produce a new project based on new analysis results made on FME. (I know that the qgis project file is an xml and so I can read it as an xml, but i am trying to build a bridge between qgis 2.18 and fme desktop 2018)

How to install the PyQGIS module and then using the custom python interpreter in FME Desktop?

I am using QGIS-ltr 2.18.23 (from OSGEO4w64) and FME 2018.1.0.1 (Win64).


7 replies

Userlevel 2
Badge +17

Hi @tono,

Please install the full version of Python on your computer, then see this page on how to install and use a custom Python interpreter in FME, to have your FME use the full version of Python.

Once you have FME running with the full Python, you can install the PyQGIS into the full Python, and the module will be usable within FME.

Badge

Is there any way of using the python interpreter, already installed for and used by QGIS, into FME desktop? Reading the documentation about PyQGIS, i have seen that the pyhton interpreter is an exe file while FME desktop points to dll's. I am not used to change the Python environment variables or interpreters, so a bit lost here :(

Userlevel 2
Badge +17

Is there any way of using the python interpreter, already installed for and used by QGIS, into FME desktop? Reading the documentation about PyQGIS, i have seen that the pyhton interpreter is an exe file while FME desktop points to dll's. I am not used to change the Python environment variables or interpreters, so a bit lost here :(

Hi @tono,

 

QGIS's Python should also install a dll. It may be in the Windows\\System32 folder (for 32 bit Python on 32 bit Windows, or 64 bit Python on 64 bit Windows), or in Windows\\SysWOW64 (32 bit Python on 64 bit Windows)

 

Badge
Hi @tono,

 

QGIS's Python should also install a dll. It may be in the Windows\\System32 folder (for 32 bit Python on 32 bit Windows, or 64 bit Python on 64 bit Windows), or in Windows\\SysWOW64 (32 bit Python on 64 bit Windows)

 

There is no *qgis* nor *py* files inside C:\\windows\\System32 folder (I am working on a windows 10 machine, 64 bits, with 64bits QGIS installed (python 2.7)). Any clue/tips?

 

 

Userlevel 2
Badge +17
There is no *qgis* nor *py* files inside C:\\windows\\System32 folder (I am working on a windows 10 machine, 64 bits, with 64bits QGIS installed (python 2.7)). Any clue/tips?

 

 

There seems to be a python27.dll in Program Files\\QGIS...\\bin. You may want to try that one.

 

 

Badge
There seems to be a python27.dll in Program Files\\QGIS...\\bin. You may want to try that one.

 

 

I have installed QGIS gjennom OSGEO4W64. So my python27.dll is inside:

 

C:\\OSGeo4W64\\bin and it does not work. I am using pythonhome:C:\\OSGeo4W64\\apps\\qgis-ltr\\python

 

And from pythoncaller, calling "from qgis.core import *" I get:

 

 

The user-specified Python interpreter `C:\\OSGeo4W64\\bin\\python27.dll' is version 2.7 with PYTHONHOME `C:\\OSGeo4W64\\apps\\qgis-ltr\\python'

 

Python version 2.7 loaded successfully

 

In a future release, FME will have reduced support for Python 2.7. Please review http://fme.ly/py27 for further information

 

ImportError: No module named site

 

 

So FME reads the right interpreter, but why is not finding "site" module??

 

 

Userlevel 2
Badge +17
I have installed QGIS gjennom OSGEO4W64. So my python27.dll is inside:

 

C:\OSGeo4W64\bin and it does not work. I am using pythonhome:C:\OSGeo4W64\apps\qgis-ltr\python

 

And from pythoncaller, calling "from qgis.core import *" I get:

 

 

The user-specified Python interpreter `C:\OSGeo4W64\bin\python27.dll' is version 2.7 with PYTHONHOME `C:\OSGeo4W64\apps\qgis-ltr\python'

 


Python version 2.7 loaded successfully

 


In a future release, FME will have reduced support for Python 2.7.  Please review http://fme.ly/py27 for further information

 


ImportError: No module named site

 

 

So FME reads the right interpreter, but why is not finding "site" module??

 

 

Hi @tono,

 

You probably need to add QGIS's Python to the python path using sys.path.append(). In your case, this would be:

 

sys.path.append('C:\\OSGeo4W64\\apps\\Python27\\lib')

Reply