|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 = '' |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
||||
|
||||
|
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. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
Well both are ways to get it to execute. Just one of the two would've been enough but heh, you never know.
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Problem going to linux from xp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|