|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SyntaxError######
I've just started using Jython. I've installed Jython2.2a0. I was just trying to run a simple hello world python program. But I'm getting an error
Code:
>>> jython hello.py
Traceback (innermost last):
(no code object) at line 0
File "<console>", line 1
jython hello.py
^
SyntaxError: invalid syntax
What cld be the problem? If anyone having basic knowledge of changing the registries cld help out... I guess there has to be a problem with the path or something. Subha ![]() |
|
#2
|
|||
|
|||
|
You are trying to call Jython from within the Jython (or Python) interactive prompt.
Run the command from the shell prompt instead. If that fails, make sure that jython is in the PATH. Dave - The Developers' Coach |
|
#3
|
|||
|
|||
|
Thanks Dave!
Quote:
Code:
C:\subha\jython22a0>jython hello.py
Traceback (innermost last):
(no code object) at line 0
File "hello.py", line 3
print 'Hello world!'
^
SyntaxError: invalid syntax
Whats the problem here? Am really sad to say this, but I don't know how to fiddle with the registry. The current scenario is as such.... Python is located at C:\Python23 There is a PTH file named pywin32 ... is that where the changes have to be made. Its contents are.... Code:
C:\Python23\Lib\site-packages\win32 C:\Python23\Lib\site-packages\win32\lib C:\Python23\Lib\site-packages\Pythonwin I tried adding the jython path here but no success. It isn't saving my changes. My Jython is located at C:\subha\jython22a0 Here I've a file named registry...I opened it in notepad n made changes to the path...what path shd I include here? the place where python is located????? I'm really confused...I've placed the hello.py in C:\subha\jython22a0 So now where am I going wrong...I've messed up the whole thing! Someone pls help out!Subha ![]() |
|
#4
|
||||
|
||||
|
Quote:
start -> run -> regedit.exe, but it's not exactly user friendly (and also not where PATH is stored). Quote:
PATH isn't stored in a text file that's easy to set - it's an environment variable. If you run start-> cmd.exe and get a command prompt, type "set" (and press enter) and you get a list of defined Environment Variables. Type "echo %PATH%" and you can see what the PATH is set to. To actually set it, so it will be there all the time, you need to go somewhere else again... Start -> Control Panel -> System -> Advanced -> Environment Variables -> System Variables I have absolutely no idea what you need to put in there though. |
|
#5
|
||||
|
||||
|
Quote:
This is what I get.... Code:
C:\>echo %PATH% c:\subha\jython22a0;c:\subha\xerces\xerces-2_6_2;c:\subha\src\pyxie3;C:\WINDOWS\ system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\nls;C:\WINDOWS\ system32\nls\ENGLISH;Z:.;Y:.;X:. Quote:
have to include Jython in the PATH.... how do I go abt it now? Subha ![]() |
|
#6
|
||||
|
||||
|
Quote:
the problem is that the print statement is indented. Python uses indentation to delimit blocks, so statements at the top level of the program must start in the first column. Quote:
You do not need to use the registry to change the path. Here is how you do it: 1) Right click on 'My Computer' and select 'Properties' 2) select the 'Advanced' tab of the dialog box 3) click on the 'Environment variables' button 4) select the 'path' environment variable and click 'Edit'. It may appear in either the 'user variables' list or the 'system variables' list, or both. If you are the only user of the computer it doesnt matter which one you pick. If there is not an entry called 'path' then create one with the 'new' button. 5) add the path to the jython directory (C:\subha\jython22a0) to the end of the string. Separate it from the other directories with a semicolon. 6) close all the dialogs in turn by clicking 'OK' The next time you open a program it will have the new path. Any programs currently open will not get the change, so close down any command prompts and reopen them. (I usually forget this and spend 10 minutes wonder why the hell my changes didn't work). Dave - The Developers Coach |
|
#7
|
|||
|
|||
|
Many thanks Dave!
Lets see how it works out Subha ![]() |
|
#8
|
|||
|
|||
|
Ok I appended Jython's path in the way you had described. I ran a python program from the command prompt and thank God it worked!
Code:
C:\JYTHON>jython greet.py Hello Earth! the thing to be noted here is that I had greet.py in my jython folder. When I removed that program and put it in my C:\Python23\Scripts folder, it doesn't work! Code:
C:\JYTHON>jython greet.py Traceback (innermost last): (no code object) at line 0 IOError: File not found - greet.py (The system cannot find the file specified) So I added python also to my path...but still no change! Then there is a registry file in Jython...called registry... Code:
# Python Registry -*- ksh -*- # This default registry sets many common options to their default values # All of these settings could be erased with no change in behavior # This is how Jim sets his path on his Windows development machine #python.path=.;c:\\Python23\\scripts# This is how Barry sets his path on his Unix development machine #python.path = /home/bwarsaw/projects/python/Lib # This is how Finn sets his path on his windows development machine #python.path = d:\\python20\\lib I changed the boldfaced comments to have path c:\\python23\\scripts but still didn't work out...how can I run a python program which is in my python folder in jython? Do I've to place all the .py programs in Jython folder only?? Subha ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > SyntaxError###### |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|