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

    Join Date
    Nov 2003
    Location
    Nowhere New York
    Posts
    46
    Rep Power
    11

    Problems making code executable


    So far I've tryed chmod [path/file], chmod +x [path/file], changing the code from txt to .py thats the only thing I've found elsewhere to change it and it hasn't worked. If you need my code it looks like this...

    #!/usr/installs/Python-2.3.2/Python
    print "Hello world!"
    raw_input("Press any key to continue...")
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    325
    Rep Power
    12
    What's the error you get ?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Nowhere New York
    Posts
    46
    Rep Power
    11
    here is some more trys and the errors I got


    root@darkstar:~# chmod 777 /usr/installs/Python-2.3.2/python hw
    chmod: failed to get attributes of `hw': No such file or directory
    root@darkstar:~# chmod 777 /usr/installs/Python-2.3.2/python hw.py
    chmod: failed to get attributes of `hw.py': No such file or directory
    root@darkstar:~# chmod 777 /usr/installs/Python-2.3.2/python /usr/installs/Python-2.3.2/Projects/hw
    root@darkstar:~# chmod 777 /usr/installs/Python-2.3.2/python /usr/installs/Python-2.3.2/Projects/hw.py
    root@darkstar:~# cd /usr/installs/Python-2.3.2/Projects
    root@darkstar:/usr/installs/Python-2.3.2/Projects# ./hw.py
    ./hw.py: line 1: print: command not found
    ./hw.py: line 2: syntax error near unexpected token `"Press any key to continue..."'
    ./hw.py: line 2: `raw_input("Press any key to continue...")'
    root@darkstar:/usr/installs/Python-2.3.2/Projects# chmod 777 /usr/installs/Python-2.3.2/python /usr/installs/Python-2.3.2/Projects/helloworld
    root@darkstar:/usr/installs/Python-2.3.2/Projects# ./helloworld
    -bash: ./helloworld: /usr/installs/Python-2.3.2/Python: bad interpreter: Permission denied
    root@darkstar:/usr/installs/Python-2.3.2/Projects# chmod 777 /usr/installs/Python-2.3.2/python /usr/installs/Python-2.3.2/Projects/helloworld.py
    root@darkstar:/usr/installs/Python-2.3.2/Projects# ./helloworld.py
    -bash: ./helloworld.py: /usr/installs/Python-2.3.2/Python: bad interpreter: Permission denied
    root@darkstar:/usr/installs/Python-2.3.2/Projects#
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    35
    Rep Power
    11
    Those are all syntax errors you're getting--try this CD'ing to the directory where the hw.py file is located, then try:

    chmod 775 hw.py

    Then, try running:

    ./hw.py

    Also, I'm curious about your python path in your first line of code. At the command prompt, type:

    which python

    The first line of your script should be #! followed by the path spit back by "which python", no spaces.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Nowhere New York
    Posts
    46
    Rep Power
    11
    root@darkstar:~# cd /usr/installs/Python/Projects
    root@darkstar:/usr/installs/Python/Projects# chmod 775 helloworld.py
    root@darkstar:/usr/installs/Python/Projects# ./helloworld.py
    Hello world!
    Press any key to continue...
    root@darkstar:/usr/installs/Python/Projects#

    Minor victory cause I got it to do something finally, but now how can I get it to do it without going into the konsole. Like when I double click it, it will make a new window and run that, or will I have to setup some kind of GUI for it through a different program?
  10. #6
  11. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Know , try this
    Code:
    #!/usr/installs/Python-2.3.2/Python
    #pgui.py
    import Tkinter
    hello=Tkinter.Label(None, text="Hello GUI world")
    hello.pack()
    hello.mainloop()
    >chmod +x pygui.py
    >pygui.py &
    Will run pygui.py in the background and create the GUI.
    Grim

IMN logo majestic logo threadwatch logo seochat tools logo