Unable to execute -m ensurepip with Jython Jar

58 views Asked by At

I am unable to execute the following command"

java -jar ~/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar -m ensurepip

I get the following stack trace. Can anyone please guide me as to what is the issue and how to solve it?

    Traceback (most recent call last):
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/runpy.py", line 161, in _run_module_as_main
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/runpy.py", line 72, in _run_code
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/ensurepip/__main__.py", line 4, in <module>
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/ensurepip/__init__.py", line 220, in _main
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/ensurepip/__init__.py", line 123, in bootstrap
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/ensurepip/__init__.py", line 45, in _run_pip
  File "/var/folders/96/llwnx0n57vd17gtfyw124z500000gq/T/tmpARwn47/pip-1.6-py2.py3-none-any.whl/pip/__init__.py", line 10, in <module>
  File "/var/folders/96/llwnx0n57vd17gtfyw124z500000gq/T/tmpARwn47/pip-1.6-py2.py3-none-any.whl/pip/util.py", line 13, in <module>
  File "/var/folders/96/llwnx0n57vd17gtfyw124z500000gq/T/tmpARwn47/pip-1.6-py2.py3-none-any.whl/pip/backwardcompat/__init__.py", line 115, in <module>
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/distutils/sysconfig.py", line 28, in <module>
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/posixpath.py", line 367, in realpath
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/posixpath.py", line 373, in _joinrealpath
  File "/Users/***/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar/Lib/posixpath.py", line 61, in isabs
AttributeError: 'NoneType' object has no attribute 'startswith'

Thanks and regards,
Paddy

Tried searching for this specific error and got this post as first search result but it didn't really helpe me.

Solution: Courtesy a github user, I got the solution from Jython github forum, please upgrade your Jython jar to 2.7.3 version and it works.

2

There are 2 answers

0
Paddy On BEST ANSWER

Solution: Courtesy of a GitHub user, I got the solution from the Jython GitHub forum, please upgrade your Jython jar to 2.7.3 version and it works.

1
BoppreH On

I've found this old post where Jython fails to populate the Python executable file name, causing it to be None. If ensurepip passes that to path.abs, you'll get the error you see here.

If that's your case, you might be able to fix it by passing the value as a -Dpython.executable variable to Java itself:

java -Dpython.executable="~/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar" -jar ~/.m2/repository/org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar -m ensurepip