Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jython.exe "2.7.0 final release" failed execution on my Windows OS

Tags:

pip

jython

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!

like image 857
mike rodent Avatar asked May 23 '15 08:05

mike rodent


People also ask

Does Jython require Python installation?

Yes. Jython is an implementation of the Python language in Java.

How do I install Jython modules?

Basic Install The installer will then walk through a similar set of steps in graphical or console mode: showing the license, selecting an install directory and JVM and actually copying Jython to the filesystem. After this completes, Jython is installed in the directory you selected.

How do I download and install the new version of Jython?

Jython 2.7.2 is distributed via an executable jar file installer. After downloadingit, either double click the jython-installer-2.7.2.jaror run java with the -jar option $ java -jar jython-installer-2.7.2.jar

How do I run a Jython script?

Executing a script in the install directory, jythonon Unix-like systems or jython.exeon Windows, will start up the Jython console, which can be used to dynamically explore Jython and the Java runtime, or to run Jython scripts. Standalone Jar

Is there a way to install Jython Without startup overhead?

The standalone option does no caching and so avoids the startup overhead (most likely at the cost of some speed in calling Java classes, but I have not profiled it) You can try it out by running the installer: $ java -jar jython-installer-2.7.2.jar

How to install Jython on a standalone machine?

The standalone option does no caching and so avoids the startup overhead (most likely at the cost of some speed in calling Java classes, but I have not profiled it) You can try it out by running the installer: $ java -jar jython-installer-2.7.2.jar then when you come to the “Installation type” page, select “Standalone”.


Video Answer


1 Answers

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.

like image 97
Jim Baker Avatar answered Sep 24 '22 21:09

Jim Baker