5

According to what I've read, sys.path should be set by PYTHONPATH. In Python, it works that way, but not in Jython. I can circumvent with -Dpython.path=... but I'd like to know why Jython isn't playing nicely.

qa@Scantron:/tmp/pip-build-qa/robotframework> echo $PYTHONPATH
/usr/lib64/python2.7
qa@Scantron:/tmp/pip-build-qa/robotframework> jython
Jython 2.2.1 on java1.7.0_17
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/share/jython/Lib', '__classpath__']
>>> ^D
qa@Scantron:/tmp/pip-build-qa/robotframework> jython -Dpython.path=/usr/lib64/python2.7
Jython 2.2.1 on java1.7.0_17
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/share/jython/Lib', '/usr/lib64/python2.7', '__classpath__']
1
  • 1
    Note that you're mixing up "Python" the language with "CPython" the implementation of it. See here. PYTHONPATH is a feature of CPython, as you can see here. Of course it's also a feature of PyPy and IronPython, but that still doesn't make it a feature of Python. Commented Jun 6, 2013 at 23:01

1 Answer 1

9

Jython does not use PYTHONPATH: you can see here a discussion.

From 2.5 onwards there is a variable that does the same: JYTHONPATH. Before that you can use the trick you already know.

Source: Jython and PYTHONPATH

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.