Ask Your Question
1

Jython: Unable to pip install requests package

asked 2019-08-01 10:33:03 -0500

daveh gravatar image

updated 2019-08-01 10:34:55 -0500

  • Installed Jython package in Streamsets container retrieved from Docker Hub and restarted.
    • Ran java -jar jython.jar -m ensurepip (in the directory where jython.jar is)
    • Ran java -jar jython.jar -m pip freeze to make sure pip was installed (it ran fine)
    • Ran java -jar jython.jar -m pip install --upgrade pip (to get pip to latest version as previous version pip version 9.x.. didn't work before)
    • Ran java -jar jython.jar -m pip install pytz to see if it would install a simple package
    • Ran java -jar jython.jar -m pip freeze to see if pytz was listsed. It was. So pip is working.
    • Ran java -jar jython.jar-m pip install requests.
    • Pip collects a number of dependencies, BUT when it get to the "chardet" package it just hangs.

This has happened on multiple attempts. The requests package installs with pip in other python versions. Wondering if its an issue with Jython.

Any insight would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-08-14 13:24:24 -0500

metadaddy gravatar image

Since requests and its dependencies are pure Python, I've been able to just use pip install (no Jython stuff) and then specify the Python package path in the Jython script:

import sys
# Set to wherever the requests package lives on your machine
sys.path.append('/Library/Python/2.7/site-packages')
import requests

I wrote a blog entry on using Jython to send data to Splunk back before we had the Splunk destination - there are step-by-step instructions there.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-08-01 10:33:03 -0500

Seen: 118 times

Last updated: Aug 14