#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    96
    Rep Power
    11

    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. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Tucson AZ
    Posts
    29
    Rep Power
    0
    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.
  4. #3
  5. onCsdfeu
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Canada
    Posts
    100
    Rep Power
    12
    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    96
    Rep Power
    11
    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
  8. #5
  9. onCsdfeu
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Canada
    Posts
    100
    Rep Power
    12
    Well both are ways to get it to execute. Just one of the two would've been enough but heh, you never know.

IMN logo majestic logo threadwatch logo seochat tools logo