I know that I can install Jython with Java and that I can use Jython where I use Python. The Jython shell is working fine.
In Jython, how can I install libraries like lxml
, Scrappy
and BeautifulSoup
that I'd normally install via pip
or easy_install
As of v2.7b4, the Jython distribution includes the ensurepip module, which simplifies installation of pip and setuptools:
Beware of sys.platform=='win32' issue that will get in your way of using PyPI packages which relying on this method to determine host platform.
Some Python modules, like
lxml
, have required components in C. These won't work in Jython.Most Python packages will work fine, and you can install them using the same tools as you use in CPython. This is described in Appendix A of Jython Book:
Testing it myself, after installing setuptools in Jython, pip installed correctly:
Being Jython though you have the power of the Java libraries, not the limitation of being unable to install a few python C libraries.
For example you would be better using Jsoup instead of Beautiful soup or go for a full solution like Jtidy.
Use Jaxp instead of lxml.
Also another option that fits your reuirements is NekoHTML
I have both CPython and Jython installed. Here is what I do if I want to install a package in Jython via pip.
For example to install the robot framework in jython (as I want to write the keyword libraries in Java), I did