Hallo!
Ich leg mal gleich los...
Habe Kate als Editor und gab das hier ein: #!/usr/bin/python print 'Hallo Welt'
Und speichere es auf mein Desktop unter: hallowelt.py
Nun öffne ich ein Terminal und gebe das hier ein: python hallowelt.py...(zum öffnen der datei)......
Doch leider kommt das dabei raus: python: can't open file 'hallowelt.py': [Errno 2] No such file or directory
Tut mir leid wegen solche Kindergarten Fragen aber könnt ihr mir bitte weiter helfen?
Anfänger Frage
- cofi
- Python-Forum Veteran
- Beiträge: 4432
- Registriert: Sonntag 30. März 2008, 04:16
- Wohnort: RGFybXN0YWR0
Nun wenn du das auf dem Desktop speicherst, dann musst du das auch dort abrufen .. dh wohl ~/Desktop wenn du KDE benutzt - was ich annehme .
python Desktop/hallowelt.py wirds dann wohl sein
Wenn du deine Datei ausführbar machst - chmod +x Desktop/hallowelt.py - , dann langt auch ein Desktop/hallowelt.py
python Desktop/hallowelt.py wirds dann wohl sein
Wenn du deine Datei ausführbar machst - chmod +x Desktop/hallowelt.py - , dann langt auch ein Desktop/hallowelt.py
- veers
- User
- Beiträge: 1219
- Registriert: Mittwoch 28. Februar 2007, 20:01
- Wohnort: Zürich (CH)
- Kontaktdaten:
In ein Verzeichnis welches sich in $PATH (/usr/bin zum bsp.) befindet. Dann kannst du das Script sogar direkt starten: $ hellowelt.pykosmonaut hat geschrieben:Wohin sollte ich die Text-Dateien speichern um sie ohne eingabe des ortes öffnen zu können?
Also nur mit python hallowelt.py ist das überhaupt möglich?
[url=http://29a.ch/]My Website - 29a.ch[/url]
"If privacy is outlawed, only outlaws will have privacy." - Phil Zimmermann
"If privacy is outlawed, only outlaws will have privacy." - Phil Zimmermann
Ich hab' mal geschrieben:
P.S.: Ein guter Platz für eigene Skripte, die von überall ausgeführt werden sollen, ist oft auch "/usr/local/bin".
HTH2. How to execute a Python-script
Executing a Python-script isn't difficult: Copy and paste its code into a text-editor ...
On Linux, I suggest learning how to use one of the editors "vim" or "emacs", but "kate", "gedit" or "kwrite" will do, too ...
Make sure, that all characters are copied and pasted correctly and that all code-indentation is kept.
Then save the script as for example "script.py" ...
On Linux, you have to make your script executable first. You can do that by executing
chmod +x script.py
After that you can run it by doing
./script.py
in its directory.
P.S.: Ein guter Platz für eigene Skripte, die von überall ausgeführt werden sollen, ist oft auch "/usr/local/bin".