Am 06.12.2010 13:04, schrieb Dobedani:
Hi folks, 

Last week I posted the following question to the usenet group comp.lang.python but unfortunately I did not get any response. Sorry for cross-posting ...

Ok here goes:
I'm new to Jython - not to Python. The good thing about Python is that 
there are many packages available which can be installed easily by 
means of setuptools. Today I installed Jython, because I'm thinking of 
integrating some Python code into a web application which will be 
hosted on a web server with Tomcat behind it plus Jython. 

I found this webpage and followed the instructions about installing 
setuptools: http://www.jython.org/jythonbook/en/1.0/appendixA.html 

Unfortunately, it did not work for me. These are the errors I got: 
C:\TEMP\jython>java -jar D:\usr\lib\jython25\jython.jar ez_setup.py 
Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py... 
Traceback (most recent call last): 
  File "ez_setup.py", line 278, in <module> main(sys.argv[1:]) 
  File "ez_setup.py", line 212, in main from 
setuptools.command.easy_install import main 
  File "C:\TEMP\jython\setuptools-0.6c11-py2.5.egg\setuptools 
\__init__.py", line 2, in <module> 
  File "C:\TEMP\jython\setuptools-0.6c11-py2.5.egg\setuptools 
\extension.py", line 2, in <module> 
  File "C:\TEMP\jython\setuptools-0.6c11-py2.5.egg\setuptools 
\dist.py", line 5, in <module> 
  File "C:\TEMP\jython\setuptools-0.6c11-py2.5.egg\setuptools\command 
\install.py", line 2, in <module> 
  File "D:\usr\lib\jython25\Lib\distutils\command\install.py", line 
15, in <module> 
    from distutils.sysconfig import get_config_vars 
  File "D:\usr\lib\jython25\Lib\distutils\sysconfig.py", line 29, in 
<module> 
    argv0_path = os.path.dirname(os.path.abspath(sys.executable)) 
  File "D:\usr\lib\jython25\Lib\ntpath.py", line 492, in abspath 
    if not isabs(path): 
  File "D:\usr\lib\jython25\Lib\ntpath.py", line 55, in isabs 
    s = splitdrive(s)[1] 
  File "D:\usr\lib\jython25\Lib\ntpath.py", line 121, in splitdrive 
    if p[1:2] == ':': 
TypeError: 'NoneType' object is unsubscriptable 

I'm suspecting the installation failed because I did not apply certain 
settings, but I don't even know how to go about that! Any help will be 
appreciated. As you'll understand I'm using Windows XP ;-) 

Kind regards ... 





I tried it myself:

C:\Users\stefan>C:\jython\jython.bat ez_setup.py
Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-p
y2.5.egg
Processing setuptools-0.6c11-py2.5.egg
Copying setuptools-0.6c11-py2.5.egg to c:\jython\lib\site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to C:\jython\bin
Installing easy_install-2.5 script to C:\jython\bin

Installed c:\jython\lib\site-packages\setuptools-0.6c11-py2.5.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

C:\Users\stefan>

If I do this:

java -jar C:\jython\jython.jar ez_setup.py

it failes as you described.


And this is because of this:

C:\Users\stefan>java -jar C:\jython\jython.jar
Jython 2.5.2b2 (Release_2_5_2beta2:7124, Sep 14 2010, 00:11:45)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_22
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.executable
None

None is none, is close to nothing. And since in splitdrive there is no check if the
object given to the method is iterable (list,tuple,string), it fails to subscript.

C:\Users\stefan>C:\jython\jython.bat
Jython 2.5.2b2 (Release_2_5_2beta2:7124, Sep 14 2010, 00:11:45)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_22
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.executable
C:\jython\jython.bat

It simply depends on how you call the jython interpreter.
Take a look ath the jython.bat, and you'll see the work that is done behind the scenes.
It is not even close to java -jar jython.jar.