Jython does not load PYTHONPATH into sys.path

爱⌒轻易说出口 提交于 2019-12-06 04:02:21

问题


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:


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



来源:https://stackoverflow.com/questions/16972853/jython-does-not-load-pythonpath-into-sys-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!