Alex you should be able to do normal python package installs using jython,
e.g.
https://stackoverflow.com/questions/6787015/how-can-i-install-various-python-libraries-in-jython

You use jython to run easy install, then you can jython easy-install pip,
then you can jython pip install whatever you want. You might need to search
around a bit to find the jython that geoserver uses, but it sounds like
you've found its location already.

It won't work for libraries that compile their own binaries, but I think
Requests is pure python so should work fine.

Also, remember from Jython you can use Java networking libraries, so you
mightn't need Requests.

Cheers
Daniel


On Tue, 5 Sep 2017 at 16:37 Alex Chen via Geoserver-users <
[email protected]> wrote:

> 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 <
> [email protected]> 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 <[email protected]>:
> > 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
> > <[email protected]> wrote:
> >
> >
> > Sorry, I meant sys.path :)
> >
> > Tõnis
> >
> > 2017-09-04 11:22 GMT+03:00 tõnis kärdi <[email protected]>:
> >> 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
> >> <[email protected]>:
> >>> 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
> >>>
> >>> [email protected]
> >>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
>
>
>
> --
> @tkardi
> skype: tonis.kardi
>
> ------------------------------------------------------------------------------
> 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
>
> [email protected]
> 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

[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to