Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 6th, 2004, 01:40 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
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

Reply With Quote
  #2  
Old December 6th, 2004, 03:55 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,254 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 8 h 9 m
Reputation Power: 265
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

Reply With Quote
  #3  
Old December 6th, 2004, 04:39 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Thanks Dave!

Quote:
Originally Posted by DevCoach
Run the command from the shell prompt instead.



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

Reply With Quote
  #4  
Old December 6th, 2004, 06:21 AM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 10
Quote:
Am really sad to say this, but I don't know how to fiddle with the registry.

start -> run -> regedit.exe, but it's not exactly user friendly (and also not where PATH is stored).

Quote:
Here I've a file named registry...
There is a PTH file named pywin32 ... is that where the changes have to be made.

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.

Reply With Quote
  #5  
Old December 6th, 2004, 06:36 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Quote:
Originally Posted by sfb
Type "echo %PATH%" and you can see what the PATH is set to.


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:
I have absolutely no idea what you need to put in there though.


have to include Jython in the PATH.... how do I go abt it now?

Subha

Reply With Quote
  #6  
Old December 6th, 2004, 03:19 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,254 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 8 h 9 m
Reputation Power: 265
Quote:
Originally Posted by NewPythoner
Thanks Dave!
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?


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:
Originally Posted by NewPythoner
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


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

Reply With Quote
  #7  
Old December 7th, 2004, 12:34 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Many thanks Dave!
Lets see how it works out

Subha

Reply With Quote
  #8  
Old December 7th, 2004, 01:21 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > SyntaxError######


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT