jython.exe “2.7.0 final release” failed execution

2019-02-14 01:55发布

OS: Windows 7, 64-bit

Here I learn that the latest version of Jython (downloads/installs as "2.7.0") includes the "ensurepip" module, which hopefully installs pip.

This is what I get... NB there is no drive "Z:" on my machine

D:\apps\jython2.7.0\bin>jython -m ensurepip
Traceback (most recent call last):
  File "<string>", line 444, in <module>
  File "<string>", line 435, in main
  File "Z:\jythondev\jython27\src\shell\build\jython\out00-PYZ.pyz\subprocess",
line 522, in call
  File "Z:\jythondev\jython27\src\shell\build\jython\out00-PYZ.pyz\subprocess",
line 710, in __init__
  File "Z:\jythondev\jython27\src\shell\build\jython\out00-PYZ.pyz\subprocess",
line 958, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified

In fact I get the above error if I simply enter "jython" [Return]!

In the readme.txt file I see this:

This is the final release of the 2.7.0 version of Jython. Along with language and runtime compatibility with CPython 2.7.0, Jython 2.7 provides substantial support of the Python ecosystem. This includes built-in support of pip/setuptools (you can use with bin/pip) and a native launcher for Windows (bin/jython.exe), with the implication that you can finally install Jython scripts on Windows.

I have no idea what they mean by "you can use with bin/pip"... the bin directory (\bin on Windoze) contains 2 files: jython.exe and python27.dll.

Furthermore I don't know how to get the interactive terminal for Jython running with this

15 mins later 2 up votes! I wasn't expecting that. I thought it was likely something anomalous I had done on my machine was to blame. Now I'm beginning to wonder whether the Jython team (who are geniuses by the way) are just so uninterested in Windoze boxes that they just packaged this up and flung it out there without testing it on any Windoze boxes at all!

a few days later Followed Jim Baker's advice: perfectly smooth installation. "pip install" working fine!

标签: pip jython
2条回答
一纸荒年 Trace。
2楼-- · 2019-02-14 02:08

JAVA_HOME must be set such that %JAVA_HOME%\bin\java.exe is the Java executable, and the target java.exe must be Java 7. See this Jython bug. It is important to note that some other possible settings for that environment variable do not work - we expect that bin\java.exe can be joined to JAVA_HOME (using os.path.join to be precise). Also it is important to set JAVA_HOME exactly per what Windows expects in terms of quoting, etc:

set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55

but not

set JAVA_HOME="C:\Program Files\Java\jdk1.7.0_55"

(Not at all the same! Just try it to see what I mean.)

The easiest way to debug these problems is with jython --print; for example on my system I get the following:

C:\jython2.7.0>set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55 C:\jython2.7.0>bin\jython.exe --print "C:\Program Files\Java\jdk1.7.0_55\bin\java" -Xmx512m -Xss1024k -classpath C:\jython2.7.0\jython.jar;. -Dpython.home=C:\jython2.7.0 -Dpython.executable=C:\jython2.7.0\bin\jython.exe -Dpython.launcher.uname=windows -Dpython.launcher.tty=true org.python.util.jython

Let me next explain the opaque error you are seeing. There are two things going on:

  1. jython.exe is actually the Jython launcher; the real Jython we use is seen in the output of jython --print; it is org.python.util.jython, plus a bunch of other options. But we need an exe so that pip and other tooling can work. On Windows (or on other OSes if profiling for example is turned on), the launcher uses subprocess to invoke the Java executable. This subprocess invocation is in line 435 of jython.py.

  2. Yes, that's jython.py. It actually uses CPython 2.7 (thanks for being around CPython, we like you!), and is wrapped into an executable by PyInstaller. The whole thing about "Z:\jythondev\jython27\src\shell\build\jython\out00-PYZ.pyz\subprocess", is due to the fact that I built jython.exe on my Z: drive, onto which my install of Windows 8.1 on VMWare has mapped my OS X homedir. (Yes, I'm completely responsible for this build.) Next, out00-PYZ.pyz refers to some internal scheme used by PyInstaller.

We need to complete the release notes wiki update I mention on that bug! And of course fix that bug so it provides a better error message and possibly can recover in certain cases.

查看更多
Explosion°爆炸
3楼-- · 2019-02-14 02:17

I also installed the Jython and was facing the same error after setting the JAVA_HOME to C:\Program Files\Java\jdk-10.0.2 works for me.

查看更多
登录 后发表回答