|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
What's the error you get ?
|
|
#3
|
|||
|
|||
|
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# |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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? |
|
#6
|
||||
|
||||
|
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() >pygui.py & Will run pygui.py in the background and create the GUI. Grim |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Problems making code executable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|