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:

To get setuptools, download ez_setup.py from http://peak.telecommunity.com/dist/ez_setup.py. Then, go to the directory where you left the downloaded file and execute:

$ jython ez_setup.py

[The easy_install script will be] installed to the bin directory of the Jython installation (/home/lsoto/jython2.5.0/bin in the example above). If you work frequently with Jython, it’s a good idea to prepend this directory to the PATH environment variable, so you don’t have to type the whole path each time you want to use easy_install or other scripts installed to this directory.

Testing it myself, after installing setuptools in Jython, pip installed correctly:

$ sudo /usr/bin/jython2.5.2b1/bin/easy_install pip
Searching for pip
[...]
Installing pip-2.5 script to /usr/bin/jython2.5.2b1/bin
Installing pip script to /usr/bin/jython2.5.2b1/bin

Installed /usr/bin/jython2.5.2b1/Lib/site-packages/pip-1.0.2-py2.5.egg
Processing dependencies for pip
Finished processing dependencies for pip

$ sudo /usr/bin/jython2.5.2b1/bin/pip install bottle
Downloading/unpacking bottle
  Downloading bottle-0.9.6.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package bottle
    Installing collected packages: bottle
  Running setup.py install for bottle
Successfully installed bottle
Cleaning up...

$ jython
Jython 2.5.2b1 (Release_2_5_2beta1:7075, Jun 28 2010, 07:44:20) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_26
Type "help", "copyright", "credits" or "license" for more information.
>>> import bottle
>>> bottle
<module 'bottle' from '/usr/bin/jython2.5.2b1/Lib/site-packages/bottle$py.class'>
>>>
Answer from user1114 on Stack Overflow
Top answer
1 of 4
43

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:

To get setuptools, download ez_setup.py from http://peak.telecommunity.com/dist/ez_setup.py. Then, go to the directory where you left the downloaded file and execute:

$ jython ez_setup.py

[The easy_install script will be] installed to the bin directory of the Jython installation (/home/lsoto/jython2.5.0/bin in the example above). If you work frequently with Jython, it’s a good idea to prepend this directory to the PATH environment variable, so you don’t have to type the whole path each time you want to use easy_install or other scripts installed to this directory.

Testing it myself, after installing setuptools in Jython, pip installed correctly:

$ sudo /usr/bin/jython2.5.2b1/bin/easy_install pip
Searching for pip
[...]
Installing pip-2.5 script to /usr/bin/jython2.5.2b1/bin
Installing pip script to /usr/bin/jython2.5.2b1/bin

Installed /usr/bin/jython2.5.2b1/Lib/site-packages/pip-1.0.2-py2.5.egg
Processing dependencies for pip
Finished processing dependencies for pip

$ sudo /usr/bin/jython2.5.2b1/bin/pip install bottle
Downloading/unpacking bottle
  Downloading bottle-0.9.6.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package bottle
    Installing collected packages: bottle
  Running setup.py install for bottle
Successfully installed bottle
Cleaning up...

$ jython
Jython 2.5.2b1 (Release_2_5_2beta1:7075, Jun 28 2010, 07:44:20) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_26
Type "help", "copyright", "credits" or "license" for more information.
>>> import bottle
>>> bottle
<module 'bottle' from '/usr/bin/jython2.5.2b1/Lib/site-packages/bottle$py.class'>
>>>
2 of 4
16

As of v2.7b4, the Jython distribution includes the ensurepip module, which simplifies installation of pip and setuptools:

jython -m ensurepip

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.

🌐
GitHub
gist.github.com β€Ί sillyfrog β€Ί bc2e8e2546247a616d97078f1e4fa060
pip in Jython Β· GitHub
You can then install any (pure Python) packages you want, for example, to install Requests: java -jar /openhab/conf/automation/jython/jython-standalone-2.7.1.jar -m pip install requests
🌐
Jython
jython.org β€Ί installation.html
Installation | Jython
The installer will then walk through a similar set of steps in graphical or console mode: showing the license, selecting an install directory and JVM and actually copying Jython to the file system. After this completes, Jython is installed in the directory you selected.
🌐
PyPI
pypi.org β€Ί project β€Ί jip
Client Challenge
JavaScript is disabled in your browser Β· Please enable JavaScript to proceed Β· A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Stack Overflow
stackoverflow.com β€Ί questions β€Ί 43699968 β€Ί how-can-i-install-python-libraries-using-jython-standalone-in-java
pip - How can I install Python libraries using Jython Standalone in Java? - Stack Overflow
import org.python.util.PythonInterpreter; public class PipInstaller{ public void installPip(){ PythonInterpreter python = new PythonInterpreter(); runEnsurePip(python); upgradePip(python); python.close(); } private void runEnsurePip(PythonInterpreter python){ StringBuilder script = new StringBuilder(); script.append("import ensurepip\n"); script.append("ensurepip._main()"); python.exec(script.toString()); } private void upgradePip(PythonInterpreter python){ StringBuilder script = new StringBuilder(); script.append("import pip\n"); script.append("pip.main(['install', '--upgrade', 'pip'])"); python.exec(script.toString()); } }
🌐
Python Software Foundation
wiki.python.org β€Ί jython β€Ί InstallationInstructions
Installation - Python Wiki
July 18, 2017 - The installer will then walk through a similar set of steps in graphical or console mode: showing the license, selecting an install directory and JVM and actually copying Jython to the filesystem. After this completes, Jython is installed in the directory you selected.
🌐
openHAB Community
community.openhab.org β€Ί setup, configuration and use β€Ί scripts & rules
How to install a PIP package into Jython - Scripts & Rules - openHAB Community
April 1, 2020 - I am trying to use the cec PIP package found here. I have the following code in $OPENHAB_CONF/automation/jsr223/python/personal/test_cec_command.py: #!/usr/bin/python import cec cec.init() tv = cec.Device(cec.CECDEVI…
Top answer
1 of 1
3

This answer is going to be really generic but I just recently have slogged my way through the setup for jython/jip/pip and here's roughly what I had to do.

Firstly, I'm running Windows 7 64 Bit from behind a proxy (work machine.)

  • Had to install jython 2.7.0 instead of 2.7.1 because (I think anyway) 2.7.1 requires admin privileges which I don't have on my work PC.
  • Pip didn't install correctly during the Jython installation and I spent an obscene amount of time trying to get it installed and functioning as I knew it from my cpython days. NOTE: Just because you get pip installed, doesn't mean you can use any package on a python package repo. As of 2.7.0, Jython doesn't have end to end capability to interpret/compile some libraries that rely on certain python wrappers of native OS function calls. I believe 2.7.1 makes solid progress in the direction of supporting all needed native calls but don't quote me on that. For example, I tried to use wxPython to make a simple GUI to test my jython install. Trying to install it from pip kept causing really non-specific error info that took me a lot of time to figure out that the cause was jython simply couldn't compile the wxPython source so beware.
  • I had to set environment variables 'http_proxy' and 'https_proxy' in the form of http://proxyhosturl:port and https://proxyhosturl:port respectively to get out from behind the proxies without having to invoke pip with the proxy switch every time I called it.
  • To actually install pip, have a look here. These instructions are for Python and Linux/Unix but the principle is roughly the same. Just use jython -m instead of python -m and ignore the '$' at the start of each command line. Also be sure to CD to your python_home/bin folder when invoking the ez_install exe.
    • If that doesn't work (didn't for me), try using get-pip.py script with these instructions https://pip.pypa.io/en/stable/installing/ (remember jython instead of python etc.). Download it, cd to the download location and follow the noted install steps. Worth noting is about half way down the install instructions where it details installing from local archives (source/binary zip or tar.gz archives of pip and setuptools as better described here: https://packaging.python.org/tutorials/installing-packages/#installing-from-local-archives). The links to the bin archives of pip and setuptools are here: https://pypi.python.org/pypi/setuptools https://pypi.python.org/pypi/pip
    • It may also be worth making sure that your PATH environment variable has the jython/bin path in the variable value. The jython installer should do this but, again, mine did not.
    • If all goes well, you should be able to invoke pip with the --version switch and if it prints a line with the installed pip version info then you should be good to go
  • Another quirky issue I had was I could invoke a function of pip one time and any subsequent times I would get a stack trace ending with something along the lines of an object not having a certain property. I fixed that by finding my temp directory by opening a windows explorer instance and typing %TEMP% in the address bar and hitting enter, it should take you to a subdir of your AppData folder and there you may see a folder with the name of the package you were trying to install and the text "_pip" somewhere in the directory name. Delete the directory and try the pip install command again. I had to do this + invoke pip install pip -U to update my install to the latest version. Then pip began behaving correctly in my instance.
  • pip search numpy (or your library name) will generate a list of results with the same logic it uses to locate your desired package when you call pip install but, again, just because it returns a matching package doesn't mean it will compile when you install it (numpy doesn't work because of the missing java to C native function calls I described earlier.) The trade off is that you can import code artifacts from Java JAR files in your Jython script files and leverage their functionality with relative ease. Between the public Java APIs available and the python packages that work with the jython interpretor, you can (in my experience) come up with a way to accomplish your task. See the following info on JIP, Maven and IDEs.

IDE and jython integration (Eclipse) - If you are stuck using Eclipse (like me) it actually has pretty decent support for python development. Install the PyDev plugin for Eclipse from Help -> Install Software. Put in this URL https://marketplace.eclipse.org/content/pydev-python-ide-eclipse, hit tab, and select the PyDev plugin and hit 'finish.' - Setup the jython interpretor info from Windows -> Preferences -> PyDev. Provide the path to your jython.jar file. - You should now be able to use File -> New PyDev project to create a basic python project and configure it to use your version of Jython and Java.

Brief Overview of Jip and Maven - jip is a jython package that is invoked very similarly to pip but instead will download JAR files from the Maven Central Repository instead of python packages from pypi.com, for example. See the install instructions described here. Note the install procedure for a global jip install which differ from just pip install jip. https://pypi.python.org/pypi/jip/ - I never got jip to work exactly as I wished because there's not a ton of documentation on it outside of what I already linked. However, if you install a JAR using jip, you have to go to your project in Eclipse and actually add the JARs themselves to your PYTHONPATH in order for import statements and editing to have intellisense and so that you don't get a classnotfound exception at runtime. See following screen shot. - There is a JIP config file that you can use similar to the pip config ini file but I have yet to find any exhaustive documentation on it's setup. Note in the above screen shot the first entry in the External libraries entries. By default, pip places installed packages in that directory so to enable eclipse to find them, you need to also ensure that location is entered.

In Conclusion - I have more to add to this answer and I will do so as soon as possible. In the meantime, see this example project I've loaded into github. https://github.com/jheidlage1222/jython_java_integration_example It shows basic config and how to interface with JARs from python code. I used the apache httpcomponents library as an example. Good luck amigo.

🌐
GitHub
github.com β€Ί OpenRefine β€Ί OpenRefine β€Ί wiki β€Ί Extending-Jython-with-pypi-modules
Extending Jython with pypi modules
June 12, 2018 - Download Jython 2.7x and install using 'standard' option (setuptools and pip will be installed)
Author Β  OpenRefine
Find elsewhere
🌐
Readthedocs
jython.readthedocs.io β€Ί en β€Ί latest β€Ί appendixA
Appendix A: Using Other Tools with Jython β€” Definitive Guide to Jython latest documentation
The primary focus of this appendix is to provide information on using some external python packages with Jython. In some circumstances, the tools must be used or installed a bit differently on Jython than on CPython, and those differences will be noted. Since there is a good deal of documentation ...
🌐
Jython
bugs.jython.org β€Ί issue2400
Issue 2400: Installing pip as part of Jython installation fails - Jython tracker
Installation Β· Mailing Lists Β· License Β· Foundation Β· Archived Sites Β· Acknowledgments Β· Issue Tracker Β· Issues Β· Show Open Β· Show Unassigned Β· Search Β· User Β· Administration Β· User List Β· Help Β· Tracker Documentation Β· Report Tracker Problem Β· Documentation Β· Current Docs Β· Jython ...
🌐
Jython
bugs.jython.org β€Ί issue2360
Issue 2360: Not installing pip on Jython - Jython tracker
Installation Β· Mailing Lists Β· License Β· Foundation Β· Archived Sites Β· Acknowledgments Β· Issue Tracker Β· Issues Β· Show Open Β· Show Unassigned Β· Search Β· User Β· Administration Β· User List Β· Help Β· Tracker Documentation Β· Report Tracker Problem Β· Documentation Β· Current Docs Β· Jython ...
🌐
TutorialsPoint
tutorialspoint.com β€Ί jython β€Ί jython_installation.htm
Jython - Installation
Download it from - https://www.jython.org/download.html and either double click on its icon or run the following command βˆ’ ... An installation wizard will commence with which installation options have to be given.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί jython-introduction-and-installation
Jython - Introduction and Installation - GeeksforGeeks
July 12, 2025 - sudo apt install jython After typing this command provide your sudo password and that's it. Linux will handle the rest. After installation, check whether Jython is installed correctly or not.
🌐
GitHub
github.com β€Ί pypa β€Ί pip β€Ί issues β€Ί 2979
pip fails to install on windows using jython 2.7.0 final Β· Issue #2979 Β· pypa/pip
July 16, 2015 - Problem The jython installer installs pip on request at installation time. This used to work, however, this stopped to work some time ago. Reproduce Fetch the jython installer over here: http://search.maven.org/remotecontent?filepath=org...
🌐
PyPI
pypi.org β€Ί project β€Ί jtypes.jython
jtypes.jython Β· PyPI
python -m pip install --upgrade jtypes.jython Β· To ensure everything is running correctly you can run the tests using: python -m jt.jython.tests Β· Visit development page Β· Installation from sources: Clone the sources and run: python -m pip ...
      Β» pip install jtypes.jython
    
Published Β  Nov 13, 2018
Version Β  0.0.3a3
🌐
Cornerpirate
cornerpirate.com β€Ί 2020 β€Ί 08 β€Ί 25 β€Ί using-jythons-pip-to-add-dependencies-to-burp-extenders
Using Jython’s PIP to add dependencies to Burp Extenders
August 8, 2021 - java -jar jython-standalone-2.7.1.jar -m ensurepip java -jar jython-standalone-2.7.1.jar -m pip install --upgrade pip java -jar jython-standalone-2.7.1.jar -m pip install jsbeautifier
Top answer
1 of 1
1

Once Jython 2.7 is installed to ~/ then:

thufir@doge:~$
thufir@doge:~$ jython --version
Jython 2.7.0
thufir@doge:~$
thufir@doge:~$ pip --version
pip 1.6.dev1 from /home/thufir/jython/Lib/site-packages (python 2.7)
thufir@doge:~$
thufir@doge:~$ pip freeze
thufir@doge:~$
thufir@doge:~$ pip install virtualenv
Downloading/unpacking virtualenv
   Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB): 1.8MB
downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
thufir@doge:~$
thufir@doge:~$ mkdir nfl
thufir@doge:~$
thufir@doge:~$ cd nfl
thufir@doge:~/nfl$
thufir@doge:~/nfl$ jython -m virtualenv jve
Cannot find file /home/thufir/jython/Include (bad symlink)
New jython executable in /home/thufir/nfl/jve/bin/jython
Installing setuptools, pip, wheel...done.
thufir@doge:~/nfl$
thufir@doge:~/nfl$ . jve/bin/activate
(jve) thufir@doge:~/nfl$
(jve) thufir@doge:~/nfl$ pip install nflgame
Collecting nflgame
/home/thufir/nfl/jve/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:310:
SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject
Name Indication) extension to TLS is not available on this platform. This
may cause the server to present an incorrect TLS certificate, which can
cause validation failures. You can upgrade to a newer version of Python to
solve this. For more information, see
https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
   warnings.warn(
/home/thufir/nfl/jve/Lib/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:115:
InsecurePlatformWarning: A true SSLContext object is not available. This
prevents urllib3 from configuring SSL appropriately and may cause certain
SSL connections to fail. You can upgrade to a newer version of Python to
solve this. For more information, see
https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
   warnings.warn(
   Downloading nflgame-1.2.20.tar.gz (34.0MB)
     100%
|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 34.0MB 11kB/s
Collecting pytz (from nflgame)
   Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
     100%
|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 491kB 158kB/s
Collecting httplib2 (from nflgame)
   Downloading httplib2-0.10.3.tar.gz (204kB)
     100%
|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 204kB 136kB/s
Collecting beautifulsoup4 (from nflgame)
   Downloading beautifulsoup4-4.5.3-py2-none-any.whl (85kB)
     100%
|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 92kB 147kB/s
Building wheels for collected packages: nflgame, httplib2
   Running setup.py bdist_wheel for nflgame ... done
   Stored in directory:
/home/thufir/.cache/pip/wheels/12/e2/67/97dfa7f48af53140aa18136c8fbf019c455600b00b6cd4f07d
   Running setup.py bdist_wheel for httplib2 ... done
   Stored in directory:
/home/thufir/.cache/pip/wheels/ca/ac/5f/749651f7925b231103f5316cacca82a487810c22d30f011c0c
Successfully built nflgame httplib2
Installing collected packages: pytz, httplib2, beautifulsoup4, nflgame
Successfully installed beautifulsoup4-4.5.3 httplib2-0.10.3 nflgame-1.2.20
pytz-2016.10
(jve) thufir@doge:~/nfl$
(jve) thufir@doge:~/nfl$ pip freeze
appdirs==1.4.0
beautifulsoup4==4.5.3
httplib2==0.10.3
nflgame==1.2.20
packaging==16.8
pyparsing==2.1.10
pytz==2016.10
six==1.10.0
(jve) thufir@doge:~/nfl$

and then:

thufir@doge:~/nfl$ 
thufir@doge:~/nfl$ . jve/bin/activate
(jve) thufir@doge:~/nfl$ 
(jve) thufir@doge:~/nfl$ jython sample.py 
L.McCoy 31 carries for 184 yards and 1 TDs
T.Pryor 13 carries for 112 yards and 0 TDs
S.Vereen 14 carries for 101 yards and 0 TDs
A.Peterson 18 carries for 93 yards and 2 TDs
R.Bush 21 carries for 90 yards and 0 TDs
(jve) thufir@doge:~/nfl$ 
(jve) thufir@doge:~/nfl$ cat sample.py 
import nflgame

games = nflgame.games(2013, week=1)
players = nflgame.combine_game_stats(games)
for p in players.rushing().sort('rushing_yds').limit(5):
    msg = '%s %d carries for %d yards and %d TDs'
    print msg % (p, p.rushing_att, p.rushing_yds, p.rushing_tds)
(jve) thufir@doge:~/nfl$ 

although it's not strictly necessary to use the virtual env.

🌐
Streamsets
community.streamsets.com β€Ί best-practice-45 β€Ί installing-and-using-python-modules-in-jython-evaluator-767
Installing and Using Python Modules in Jython Evaluator. | StreamSets Community
February 17, 2022 - Installing and Using Python Modules in Jython Evaluator. If you've installed a library such as python-grok using pip, you can simply add it to your PYTHONPATH in the Jython Processor.