<div dir="ltr">The reason in using processing.runalg() is to integrate processing workflows from qgis (that can be exported in Python) and try to publish via PyWPS.<div>So the "extract nodes" is only an example for check that this could be done in WPS.</div><img width="0" height="0" class="mailtrack-img" src="https://mailtrack.io/trace/mail/dd2d26af28c0687837d7bb69f76e4a18d8a1f0e1.png?u=394009"></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-05 11:54 GMT-02:00 Jáchym Čepický <span dir="ltr"><<a href="mailto:jachym.cepicky@gmail.com" target="_blank">jachym.cepicky@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm afraid, I do not know much about QGIS. I have no clue about how it's processing module is organized.<br>
<br>
What about using shapely or fiona for this task?<br>
<br>
J<br>
<br>
Dne 5.1.2017 v 14:40 Eduardo Silverio da Silva napsal(a):<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Problem solved!<br>
<br>
The problem is that each time that I change the PATHs, the Apache need to<br>
be restarted to update the environment variables.<br>
Also I realized that only the PYTHONPATH in Windows is not recognized in<br>
the way that I have done before (Control Panel>Advanced system<br>
settings>Environment Variables), so I needed to put the paths in a archive<br>
that my Python could read "C:\Pytho27\paths.pth".<br>
Now I can import qgis.core and even the plugin "processing" from qgis.<br>
<br>
But here is another question: How to run the algorithm Extract Nodes on a<br>
local Shapefile?<br>
<br>
# In my IDLE Python, I do this by typing:<br>
from qgis.core import QgsApplication<br>
from processing.core.Processing import Processing<br>
import processing<br>
qgis = QgsApplication([], True)<br>
qgis.setPrefixPath('C:/Program Files/QGIS 2.18/apps/qgis', True)<br>
qgis.initQgis()<br>
Processing.initialize()<br>
processing.runalg('qgis:extrac<wbr>tnodes', 'C:\river.shp', 'C:\result.shp')<br>
<br>
# But when I try in PyWPS, the program stops in "Processing.initialize()",<br>
then I need to kill the process.<br>
<br>
Any suggestions?<br>
<br>
Thanks<br>
<br></span><div><div class="h5">
2017-01-02 19:54 GMT-02:00 Eduardo Silverio da Silva <<br>
<a href="mailto:eduardosilverio1990@gmail.com" target="_blank">eduardosilverio1990@gmail.com</a>><wbr>:<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi,<br>
<br>
The way I configured the path was by accessing: Control Panel > System and<br>
Security > System > Advanced system settings > Environment Variables...<br>
(Image attached)<br>
<br>
I also have tested with the following code just at the begining of the<br>
code:<br>
<br>
import sys<br>
sys.path.append("C:\Program Files (x86)\QGIS 2.18\bin")<br>
sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\qgis\bin")<br>
sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\qgis\python")<br>
sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\Python27\Lib\site-<br>
packages")<br>
sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\qgis\python\plugins"<br>
)<br>
<br>
and I got the same error: "No module named qgis.core".<br>
<br>
Well, thanks by the help!<br>
<br>
Eduardo<br>
<br>
2017-01-02 18:56 GMT-02:00 Jáchym Čepický <<a href="mailto:jachym.cepicky@gmail.com" target="_blank">jachym.cepicky@gmail.com</a>>:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Well,<br>
<br>
I have no idea, how you confiured the PYTHONPATH<br>
<br>
but try (already proposed)<br>
<br>
import sys<br>
sys.path.append("/path/to/qgis<wbr>/")<br>
<br>
J<br>
<br>
Dne 2.1.2017 v 21:54 Eduardo Silverio da Silva napsal(a):<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have checked the GetCapabilities by accessing:<br>
<a href="http://localhost:8080/cgi-bin/pywps.cgi?service=wps&request=" rel="noreferrer" target="_blank">http://localhost:8080/cgi-bin/<wbr>pywps.cgi?service=wps&request=</a><br>
GetCapabilities&version=1.0.0<br>
and it is okay. I can even execute the example process "inputs_added".<br>
<br>
Then a have checked the log messages and the result is:<br>
<br>
PyWPS [2017-01-02 18:49:34,355] INFO: Setting PYWPS_PROCESSES from<br>
configuration file to c:/pywps/pywps_processes<br>
PyWPS [2017-01-02 18:49:34,388] WARNING: Could not import processes from<br>
'pywps_processes': ImportError('No module named qgis.core',)<br>
PyWPS [2017-01-02 18:49:34,424] INFO: Following processes are imported:<br>
['inputs_added']<br>
Traceback (most recent call last):<br>
  File "C:/pywps\pywps\Wps\__init__.p<wbr>y", line 174, in<br>
_init_from_directory<br>
    [processSources.__name__])<br>
  File "c:/pywps/pywps_processes\proc<wbr>essing.py", line 2, in <module><br>
    from qgis.core import *<br>
ImportError: No module named qgis.core<br>
<br>
As we can see, the only process imported was the "input_added", while my<br>
other algorithm "processing" gave an ImportError.<br>
<br>
Eduardo,<br>
<br>
2017-01-02 18:42 GMT-02:00 Jáchym Čepický <<a href="mailto:jachym.cepicky@gmail.com" target="_blank">jachym.cepicky@gmail.com</a>>:<br>
<br>
Hi,<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
first check, if your GetCapabilities response is ok (<br>
<a href="http://server/wps?service=wps&request=getcapabilities" rel="noreferrer" target="_blank">http://server/wps?service=wps&<wbr>request=getcapabilities</a>) - maybe the<br>
plugin<br>
is corrupted (it's not the stablest piece of software).<br>
<br>
Then please one more time: check the error.log of your web server, there<br>
should be written more - you can pass any exception or error message<br>
either<br>
to the mailing list or share it via <a href="http://pastebin.net" rel="noreferrer" target="_blank">pastebin.net</a> or similar service<br>
<br>
J<br>
<br>
Dne 2.1.2017 v 21:38 Eduardo Silverio da Silva napsal(a):<br>
<br>
In my case I am using QGIS 2.18 (x32) and Python 2.7.13 (x32) on Windows<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
10, and I have already added the following environment variables:<br>
<br>
PYTHONPATH:<br>
C:\Program Files (x86)\QGIS 2.18\apps\qgis\python<br>
C:\Program Files (x86)\QGIS 2.18\apps\qgis\python\plugins<br>
C:\Program Files (x86)\QGIS 2.18\apps\Python27\Lib\site-pa<wbr>ckages<br>
<br>
PATH:<br>
C:\Program Files (x86)\QGIS 2.18\bin<br>
C:\Program Files (x86)\QGIS 2.18\apps\qgis\bin<br>
C:\Python27<br>
C:\Python27\Scripts<br>
<br>
Here is the code where I want to import the classes:<br>
<br>
#I would like to use these classes:<br>
# from qgis.core import *<br>
# from qgis.gui import *<br>
# from processing.core.Processing import Processing<br>
# import processing<br>
<br>
from pywps.Process import WPSProcess<br>
from types import FloatType<br>
<br>
class Process(WPSProcess):<br>
     def __init__(self):<br>
         WPSProcess.__init__(self,<br>
              identifier       = "processar",<br>
              title            = "Title",<br>
              version          = "1",<br>
              storeSupported   = "false",<br>
              statusSupported  = "false",<br>
              abstract         = "Abstract")<br>
<br>
         self.value1 = self.addLiteralInput(identifie<wbr>r = "value1",<br>
title<br>
=<br>
"Input 1", type = FloatType)<br>
         self.value2 = self.addLiteralInput(identifie<wbr>r = "value2",<br>
title<br>
=<br>
"Input 2", type = FloatType)<br>
         self.result = self.addLiteralOutput(identifi<wbr>er = "result",<br>
title =<br>
"Result", type = FloatType)<br>
<br>
     def execute(self):<br>
    # Here I would like to write the necessary code to execute the<br>
qgis:extractnodes algorithm:<br>
    # processing.runalg('qgis:extrac<wbr>tnodes', 'river.shp',<br>
'output.shp')<br>
<br>
v1 = self.value1.getValue()<br>
         v2 = self.value2.getValue()<br>
         self.result.setValue(v1 + v2)<br>
         return<br>
------------------------------<wbr>--------<br>
<br>
But even with those PATH variables configured I could not access the<br>
algorithm via WPS-client plugin.<br>
<br>
Regards,<br>
<br>
<br>
2017-01-02 17:31 GMT-02:00 Salvatore Larosa <<a href="mailto:lrssvtml@gmail.com" target="_blank">lrssvtml@gmail.com</a>>:<br>
<br>
Hi,<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Mon, Jan 2, 2017 at 4:31 PM, Eduardo Silverio da Silva <<br>
<a href="mailto:eduardosilverio1990@gmail.com" target="_blank">eduardosilverio1990@gmail.com</a>> wrote:<br>
<br>
Hello people,<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I have a python script that uses some classes from qgis and it runs<br>
correctly in my standalone app (IDLE Python). But when I try to<br>
publish<br>
the<br>
script through PyWPS (3.2.5), the process does not apear in the list<br>
of<br>
GetCapabilities. I think the problem is with the following imports:<br>
<br>
from qgis.core import *<br>
from qgis.gui import *<br>
from processing.core.Processing import Processing<br>
<br>
When I comment these lines the algorithm is showed.<br>
<br>
<br>
I guess the problem is with your environment variable, you should<br>
</blockquote>
add the<br>
QGIS python and plugins paths to PYTHONPATH and probably the QGIS lib<br>
path<br>
to LD_LIBRARY.<br>
<br>
Also, any error message could be useful in order to get some help from<br>
the<br>
community. :)<br>
<br>
Regards,<br>
-SL<br>
<br>
<br>
--<br>
Salvatore Larosa<br>
linkedIn: <a href="http://linkedin.com/in/larosasalvatore" rel="noreferrer" target="_blank">http://linkedin.com/in/larosas<wbr>alvatore</a><br>
twitter: @lrssvt<br>
skype: s.larosa<br>
IRC: lrssvt on freenode<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
pywps-dev mailing list<br>
<a href="mailto:pywps-dev@lists.osgeo.org" target="_blank">pywps-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pywps-dev" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/pywps-dev</a><br>
<br>
<br>
--<br>
</blockquote>
Jachym Cepicky<br>
e-mail: <a href="mailto:jachym.cepicky@gmail.com" target="_blank">jachym.cepicky@gmail.com</a><br>
twitter: @jachymc<br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
</blockquote>
--<br>
Jachym Cepicky<br>
e-mail: <a href="mailto:jachym.cepicky@gmail.com" target="_blank">jachym.cepicky@gmail.com</a><br>
twitter: @jachymc<br>
<br>
</blockquote>
<br>
<br>
<br></div></div><span class="">
--<br>
Eduardo Silverio da Silva<br>
Mestrando em Ciências Geodésicas na Universidade Federal do Paraná<br>
Engenheiro Cartógrafo e Agrimensor<br>
</span><a href="tel:%2B55%2041%2099873-6274" value="+5541998736274" target="_blank">+55 41 99873-6274</a> <+55%2041%2099873-<wbr>6274><br>
<br>
</blockquote>
<br>
<br>
<br>
</blockquote><div class="HOEnZb"><div class="h5">
<br>
-- <br>
Jachym Cepicky<br>
e-mail: <a href="mailto:jachym.cepicky@gmail.com" target="_blank">jachym.cepicky@gmail.com</a><br>
twitter: @jachymc<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><span style="font-size:12.8000001907349px">Eduardo Silverio da Silva</span><br></div><div>Mestrando em Ciências Geodésicas na Universidade Federal do Paraná</div><div>Engenheiro Cartógrafo e Agrimensor</div><div>+55 41 99873-6274</div></div></div></div></div></div></div></div></div>
</div>