8

I have set the variables JYTHON_HOME to the directory where I have installed Jython and JYTHON_PATH to the bin folder, but I still get the following error when I try to run jython:

'jython' is not recognized as an internal or external command,
operable program or batch file.

Why do I get this error? The Java installation has no issues.

Paolo
  • 20,112
  • 21
  • 72
  • 113
Bharath Gupta
  • 344
  • 3
  • 8
  • 20
  • Just add `%JYTHON_HOME\bin%` to your `PATH`. Open new Terminal and type `jython`, it will work. – hygull Apr 30 '18 at 10:19

2 Answers2

8

I am Windows user & I have installed Jython in C:\jython2.7.0.

What I had before?

I had neither set the JYTHON_HOME environment variable nor added %JYTHON_HOME%\bin to PATH environment variable. I also got the same error as shown in the question.

How I fixed?

  • I created new environment variable named JYTHON_HOME with value C:\jython2.7.0.

You've to use your own Jython's installation folder.

enter image description here

  • Then I added %JYTHON_HOME%\bin to PATH environment variable as the below 2 image shows.

Create new PATH environment variable if it is not already there (This is rare case).

enter image description here

  • Open new Terminal and type jython, it will work. Now you can try executing simple Python statements as the below image shows.

Do not use the already opened Terminal.

enter image description here

That's it.

hygull
  • 8,464
  • 2
  • 43
  • 52
5

You still need to add the path to the executable jython.bat to your PATH environment variable. Here as an example I'm providing my ini-jython.bat, which I use before executing my jython project (in this case it's a Django on Jython project, you can safely ignore the Django stuff, or adapt it to your needs):

set JYTHON_HOME=c:\tools\jython2.5.2
set PATH=%JYTHON_HOME%\bin;%PATH%
set CLASSPATH=dep1;dep1/lib/*;_lib/*
set JYTHONPATH=.;..\django-debug-toolbar;..\django-common
set DJANGO_SETTINGS_MODULE=site_projname.settings
set PYTHONPATH=%JYTHONPATH%
set manage=jython c:\tools\jython2.5.2\bin\django-admin.py
set makemessages=django-admin makemessages --extension html,py
set compilemessages=django-admin compilemessages
Sirs
  • 1,277
  • 17
  • 30
  • Thank Sirs. Could you please give me clear idea about jython.bat path – Bharath Gupta Nov 16 '11 at 09:02
  • 2
    The PATH system variable indicates where the system can look for executables. jython.bat is the jython executable, it should be inside the directory in which you've installed jython, in the "/bin/" subfolder. For example if you've installed jython in "c:\tools\jython", you'll need to modify your path environment variable to include "c:\tools\jython\bin". You'd achieve this by executing: "SET PATH=c:\tools\jython\bin;%PATH%" . With this sentence you're asking the system to modify the PATH variable to include the jython bin folder followed by the existing contents of the PATH variable (%PATH%). – Sirs Nov 16 '11 at 09:15