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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 15th, 2003, 09:39 AM
phidoux phidoux is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 96 phidoux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 17 sec
Reputation Power: 5
Problem going to linux from xp

Ok I made this program using IDLE and it runs perfect in windows xp.. when I try to run it on redhat linux it gives me the following errors

[python@ python]$ ./ksconfigwriter.py
./ksconfigwriter.py: line 2: import: command not found
./ksconfigwriter.py: line 6: syntax error near unexpected token `('
./ksconfigwriter.py: line 6: `def fileExists(f):'


I was wondering what I could do to get it to work... the first part of my code looks like this

Thank you in advance...


# Libs ----------------------------------------------
import sys,os,string,time

##open the name of the output file according to the user's selection

def fileExists(f):
try:
file = open(f)
except IOError: #no it doesn't exist
exists = '0'
else: #yes it does exist
exists = '1'
return exists
#----------------------------------------------------


print ("\n\n")
overwrite = ''

while overwrite != 'y':
overwrite = ''

Reply With Quote
  #2  
Old October 15th, 2003, 10:51 AM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
I'm about as newbie as it gets when it comes to linux. I never use it except for one course in college - over a year ago... but I searched on the internet for "import: command not found" and saw references to other threads about linux settings that caused this - somehting you may want to try - I really hope it helps, again I don't know anything about linux to offer any other suggestions.

Reply With Quote
  #3  
Old October 16th, 2003, 12:30 AM
SolarBear's Avatar
SolarBear SolarBear is offline
onCsdfeu
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 100 SolarBear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 7 m 43 sec
Reputation Power: 6
Send a message via ICQ to SolarBear Send a message via MSN to SolarBear
I think I know what's wrong : you're executing the file but you're not specifying which interpreter to use. Your Linux may be trying to interprete it using your shell (bash, csh, etc.) and doesn't understand what 'import' means.

Try typing python ksconfigwriter.py at command line if Python is in your path variable, or you could add
Code:
#!/usr/bin/env python

as the first line in your file, and then call it as you did. While this may be only a comment, it will indicate where your interpreter is located. Change the file path according to your system, of course.

Reply With Quote
  #4  
Old October 16th, 2003, 11:59 AM
phidoux phidoux is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 96 phidoux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 17 sec
Reputation Power: 5
Thank you SolarBear your solution worked perfectly. I don't know which part but it did work when I did both so thank you very much.

Phidoux

Reply With Quote
  #5  
Old October 16th, 2003, 09:41 PM
SolarBear's Avatar
SolarBear SolarBear is offline
onCsdfeu
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 100 SolarBear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 7 m 43 sec
Reputation Power: 6
Send a message via ICQ to SolarBear Send a message via MSN to SolarBear
Well both are ways to get it to execute. Just one of the two would've been enough but heh, you never know.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Problem going to linux from xp


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 3 hosted by Hostway