简体   繁体   English

如何为Jython设置环境变量?

[英]How do I set the Environment variables for Jython?

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_HOME设置为我已将Jython和JYTHON_PATH安装到bin文件夹的目录,但是当我尝试运行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. Java安装没有问题。

You still need to add the path to the executable jython.bat to your PATH environment variable. 您仍然需要将可执行文件jython.bat的路径添加到PATH环境变量中。 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): 这里作为一个例子,我提供了我的ini-jython.bat,我在执行我的jython项目之前使用它(在这种情况下,它是一个关于Jython项目的Django,你可以安全地忽略Django的东西,或者根据你的需要调整它):

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

I am Windows user & I have installed Jython in C:\\jython2.7.0 . 我是Windows用户,我在C:\\jython2.7.0安装了Jython。

What I had before? 我之前有什么?

I had niether set the JYTHON_HOME environment variable nor added %JYTHON_HOME%\\bin to PATH environment variable. 我没有设置JYTHON_HOME环境变量,也没有将%JYTHON_HOME%\\bin添加到PATH环境变量中。 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 . 我创建了名为JYTHON_HOME新环境变量,其值为C:\\jython2.7.0

    You've to use your own Jython's installation folder. 您将使用自己的Jython安装文件夹。

在此输入图像描述

  • Then I added %JYTHON_HOME%\\bin to PATH environment variable as the below 2 image shows. 然后我将%JYTHON_HOME%\\bin添加到PATH环境变量,如下图2所示。

    Create new PATH environment variable if it is not already there (This is rare case). 如果它尚不存在,则创建新的PATH环境变量(这种情况很少见)。

在此输入图像描述

  • Open new Terminal and type jython , it will work. 打开新的终端并输入jython ,它会起作用。 Now you can try executing simple Python statements as the below image shows. 现在您可以尝试执行简单的Python语句,如下图所示。

    Do not use the already opened Terminal. 不要使用已打开的终端。

在此输入图像描述

That's it. 而已。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM