Sublime Forum

Run with python

#1

Hello I just come to begin to learn python I thus downloaded sublim text but impossible to execute a program when I make “F7” that just writes " finished in 0.158 second " even when I want to execute a program so simple as " print (" hello “)”
help me please…

0 Likes

#2

Can you show us the source of the python file you’re trying to execute?

0 Likes

#3

i have just trying to execute a “print (“hello”)” in sublime text
in tool i have "save all on build " and in build systeme “python” and my file is save in “.py”

0 Likes

#4

If your file is “test.py” and you have

print ('hello')

in it, just select Tools > Build and you should see “hello” pop up in the console.

0 Likes

#5

I have selected save all on build
my programme is test.py
and in build system i have selected python
but when i select build (F7) it’s just write “finished in 0.014 seconds”

0 Likes

#6

nobody knows the solution ?

0 Likes

#7

Does the script work from the command line?

0 Likes

#8

no …when i write my script i can’t run it … it only write “finished in …” in the outpout panel

0 Likes

#9

nobody knows how can i run my programm ?

0 Likes

#10
print('hello')

is a Python 3 syntax (maybe work in Python 2.7, not sure…)
ST2 use a Python 2.6 interpreter so the code is:

print 'hello'
0 Likes

#11

I’ve often wondered this same thing, never got it to work.
My program: print ‘hello’. Saved in test.py.
Hit F7, I see this result pop up:
[Error 2] The system cannot find the file specified
[Finished]

If I view the console, this is what I see:

Writing file /C/project/test.py with encoding UTF-8 Running python -u C:\project\test.py Running python -u C:\project\test.py
I couldn’t help but notice the UNIX path when saving the file, and the WINDOWs path when trying to run it. Could that be the problem?

0 Likes

#12

i try print ‘hello’ but when i run it’s open output panel and write finish in 0.14 second nothing else …

0 Likes

#13

It’s possible your program ‘is’:

  • Running.
  • Finishing.
  • And then closing.
    Almost instantly because you are only giving it the command: print(‘hello’)
    before the program ends.

Try writing this on the line after: print(‘hello’)

input("Press the enter key to exit.")What this will do is cause the program to wait for user input then continue. And since there is nothing more, it will end.

The (finish in 0.14) output you are seeing reminds me of this however I’m new to Python myself so I could be wrong about this.

0 Likes

#14

Good thread.I like the views of the members. It contains nice information. Thanks for sharing this thread with me.

0 Likes