Alex, when copying requests to "{GEOSERVER_DATA}/scripts/lib/py/", did you copy all required dependencies aswell? If not then that might explain the "package not found" error.
$ pip show requests [...] Requires: urllib3, idna, chardet, certifi $ So pip installing a package in your desired location is a better alernative than simply copying. All the best, Tõnis 2017-09-05 9:36 GMT+03:00 Alex Chen <tttchen2...@yahoo.com>: > Hi Tõnis, > > Thanks for the info. > > I know the pip way to install new packages on native Python. But GeoServer > does not seem to use the native Python on the OS but Jython in the > WEB-INF/lib. I tried to copy the installed package to > "{GEOSERVER_DATA}/scripts/lib/py/" and restarted GeoServer. I imported the > package in the Python script and copied the file to > "{GEOSERVER_DATA}\scripts\apps\hello\main.py". When I called the app url via > HTTP as instructed in the documentation, it complained about "unable to find > the module xxx". > > Hope someone could give any clue about it. > > Thanks. > > Cheers, > Alex > > On Tuesday, 5 September 2017, 4:22:06 pm AEST, tõnis kärdi > <tonis.ka...@gmail.com> wrote: > > > Hey Alex, > > You can use e.g pip https://pip.pypa.io/en/stable/ but I guess any > Python package manager will do. With pip it would be smth like: > > pip install packagename -t /the/path/you/want > > Maybe there's a way through simply setting environment variables > aswell to use your existing modules. But not really sure, I don't know > enough about jython/java for that matter. > > All the best, > Tõnis > > > 2017-09-05 3:05 GMT+03:00 Alex Chen <tttchen2...@yahoo.com>: >> Thanks Tõnis! >> >> Here is the output to the sys.path in my script when run by GeoServer: >> >> ['C:\\geoserver_data\\scripts\\lib\\py', 'C:\\Program Files >> (x86)\\GeoServer >> 2.11.2\\webapps\\geoserver\\WEB-INF\\lib\\Lib', 'C:\\Program Files >> (x86)\\GeoServer >> 2.11.2\\webapps\\geoserver\\WEB-INF\\lib\\jython-2.7.0.jar\\Lib', >> '__classpath__', '__pyclasspath__/'] >> >> >> Obviously the "requests" python library is not contained in any of the >> paths >> above. So the question is how I can install "requests" so that GeoServer >> can >> use. The official documentation does not offer any clue in this aspect. >> >> Much appreciated! >> >> Cheers, >> Alex >> >> >> On Monday, 4 September 2017, 8:52:03 pm AEST, tõnis kärdi >> <tonis.ka...@gmail.com> wrote: >> >> >> Sorry, I meant sys.path :) >> >> Tõnis >> >> 2017-09-04 11:22 GMT+03:00 tõnis kärdi <tonis.ka...@gmail.com>: >>> Hi Alex, >>> >>> did you check what os.sys.path outputs in a script run by GeoServer? >>> Maybe it's just that requests is not on an importable path? >>> >>> All the best, >>> Tõnis >>> >>> 2017-09-04 4:38 GMT+03:00 Alex Chen via Geoserver-users >>> <geoserver-users@lists.sourceforge.net>: >>>> Dear all, >>>> >>>> I am with GeoServer 2.11.2 and am planning to do some scripting on it. >>>> >>>> I would like to run some custom Python scripts either as Apps that can >>>> be >>>> called via http or as WPS services. I have managed to install the >>>> scripts >>>> plugin on GeoServer, and the "apps" and "wps" folders are both visible >>>> in >>>> the "scripts" parent folder. >>>> >>>> I have tried to save some custom scripts in the apps folder and called >>>> via >>>> http, for instance, "http://localhost:8090/geoserver/script/apps/hello", >>>> but >>>> it failed due to "unable to find packages". Those packages that >>>> GeoServer >>>> was unable to find include "requests" and "urllib2" etc but I am pretty >>>> sure >>>> they were both installed properly on the Python. I am wondering how >>>> GeoServer gets to know where the Python (2.7.13) directory is and how >>>> Python >>>> gets utilised by GeoServer on my computer via either http or wps. >>>> >>>> I have posted some questions on stackoverflow, but haven't received much >>>> positive reply. >>>> >>>> Much appreciated! >>>> >>>> Alex >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Check out the vibrant tech community on one of the world's most >>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >>>> _______________________________________________ >>>> Geoserver-users mailing list >>>> >>>> Please make sure you read the following two resources before posting to >>>> this >>>> list: >>>> - Earning your support instead of buying it, but Ian Turton: >>>> http://www.ianturton.com/talks/foss4g.html#/ >>>> - The GeoServer user list posting guidelines: >>>> http://geoserver.org/comm/userlist-guidelines.html >>>> >>>> Geoserver-users@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Geoserver-users mailing list Please make sure you read the following two resources before posting to this list: - Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/ - The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users