<div dir="ltr">Problem solved!<div><br></div><div>The problem is that each time that I change the PATHs, the Apache need to be restarted to update the environment variables.</div><div>Also I realized that only the PYTHONPATH in Windows is not recognized in the way that I have done before (<span style="font-size:12.8px">Control Panel</span><span style="font-size:12.8px">>Advanced system settings>Environment Variables), so I needed to put the paths in a archive that my Python could read "C:\Pytho27\paths.pth".</span></div><div><span style="font-size:12.8px">Now I can import qgis.core and even the plugin "processing" from qgis.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">But here is another question: How to run the algorithm Extract Nodes on a local Shapefile?</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"># In my IDLE Python, I do this by typing:</span><br></div><div><span style="font-size:12.8px">from qgis.core import QgsApplication</span><br></div><div><span style="font-size:12.8px">from processing.core.Processing import Processing</span><br></div><div><span style="font-size:12.8px">import processing</span></div><div><span style="font-size:12.8px">qgis = QgsApplication([], True)</span><br></div><div><span style="font-size:12.8px">qgis.setPrefixPath('C:/Program Files/QGIS 2.18/apps/qgis', True)</span><br></div><div><span style="font-size:12.8px">qgis.initQgis()</span><br></div><div><span style="font-size:12.8px">Processing.initialize()</span><br></div><div><span style="font-size:12.8px">processing.runalg('qgis:extractnodes', 'C:\river.shp', 'C:\result.shp')</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"># But when I try in PyWPS, the program stops in "Processing.initialize()", then I need to kill the process.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Any suggestions?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks</span></div><img width="0" height="0" class="mailtrack-img" src="https://mailtrack.io/trace/mail/80bea4578bb80b00e7091b2dcb8512c047fa51ee.png?u=394009"></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-02 19:54 GMT-02:00 Eduardo Silverio da Silva <span dir="ltr"><<a href="mailto:eduardosilverio1990@gmail.com" target="_blank">eduardosilverio1990@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>The way I configured the path was by accessing: Control Panel > System and Security > System > Advanced system settings > Environment Variables... (Image attached)</div><div><br></div><div>I also have tested with the following code just at the begining of the code:</div><div><br></div><div><div>import sys</div><div>sys.path.append("C:\Program Files (x86)\QGIS 2.18\bin")</div><div>sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\qgis\bin")</div><div>sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\qgis\python")</div><div>sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\Python27\Lib\site-<wbr>packages")</div><div>sys.path.append("C:\Program Files (x86)\QGIS 2.18\apps\qgis\python\plugins"<wbr>)</div></div><div><br></div><div>and I got the same error: "No module named qgis.core".</div><div><br></div><div>Well, thanks by the help!</div><div><br></div><div>Eduardo</div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">2017-01-02 18:56 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">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>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
I have checked the GetCapabilities by accessing:<br>
<a href="http://localhost:8080/cgi-bin/pywps.cgi?service=wps&request=GetCapabilities&version=1.0.0" rel="noreferrer" target="_blank">http://localhost:8080/cgi-bin/<wbr>pywps.cgi?service=wps&request=<wbr>GetCapabilities&version=1.0.0</a><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 _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></span><div><div class="m_8307618649413817814h5">
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>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<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 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 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>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In my case I am using QGIS 2.18 (x32) and Python 2.7.13 (x32) on Windows<br>
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", title<br>
=<br>
"Input 1", type = FloatType)<br>
         self.value2 = self.addLiteralInput(identifie<wbr>r = "value2", 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', '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>
<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>
<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 publish<br>
the<br>
script through PyWPS (3.2.5), the process does not apear in the list 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>
</blockquote>
I guess the problem is with your environment variable, you should 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>
</blockquote>
<br>
<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>
</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></blockquote><div class="m_8307618649413817814HOEnZb"><div class="m_8307618649413817814h5">
<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></div><img width="0" height="0" class="m_8307618649413817814mailtrack-img" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"><span class=""><div><br></div>-- <br><div class="m_8307618649413817814gmail_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><a href="tel:+55%2041%2099873-6274" value="+5541998736274" target="_blank">+55 41 99873-6274</a></div></div></div></div></div></div></div></div></div>
</span></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>