How To: Run Python 2.7 and Python 3.5 Script in Sublime Text 3

preview_player
Показать описание
A quick tutorial on how to run either a Python 2.7 script or a Python 3.5 script using Sublime Text 3.

The contents of the sublime-build file are:

{
"cmd": ["/usr/bin/python3", "$file"],
"file_regex": "file \"(...*?)\", line([0-9]+)"
}

If you are using either Mac or Windows, instead of using the "whereis" command to find your installation path to Python, you can just run the following script, which will output the path to where Python is installed on your machine:

```
import os
import sys
```

Website:
Рекомендации по теме
Комментарии
Автор

Thank you so much for this tutorial. I've been struggling with this for a long time.

tiffblahthegiraffe
Автор

Just getting started with computer science. This was a life saver. Thank you so much!

jasonlin
Автор

Just the video I was looking for ! Thank you .

dhf
Автор

Many thanks for excellent tutorial, it worked just fine under Linux Mint. This tutorial actually enabled me to run my Python script, whereas a number of other tutorials covered Sublime in considerable detail without including the 'how to run' details'.

kurtmiller
Автор

thank you so much for your clear and straight-to-the-point video

alaindiouly
Автор

you are a life saver! thank you very much.

henryriehl
Автор

I was about to just give up on being a software developer... until I finally got it lol. I'm on a Mac, so I was having trouble just like everyone else. Here's what worked finally,

{
"cmd": ["/Library/Frameworks/Python.framework/Versions/3.7/bin/python3", "$file"],
"selector": "source.python",
"file_regex": "file \"(...*?)\", line([0-9]+)"
}

Make sure to keep that "$file" in there, and just add the part to it WITH a comma as show above. Also, you can use type -a python3 in terminal to find out where your python3 is located. Your welcome!

ThePassportPapi
Автор

really this is very useful to me
i have strugglith with this for a long time
thanks you a lot

jitendramaurya
Автор

that was pretty helpful man, thank you

anasswakach
Автор

Thank you! It's working (13/8/2020)

cheatgaming
Автор

you are the best thank you so much <3

ghadajw
Автор

Do you know if it's possible to install/select multiple python versions from within cygwin (cygcheck -c)?

In Windows, I have 3 batch files that I use to setup the PATH depending if I need it to point to python 2.7 (32-bit, or 64 bit) or 3.8 (64 bit). But can something similar be done in cygwin?

bennguyen
Автор

In the new versions of mac OS, the command whereis sometimes doesn't work, instead, you could try the command -which python3-. Hopefully it can helps you.

christianpiconcalderon
Автор

it says python is not recognized as an internal command, operable program or batch file plllsss help!

VonMoments
Автор

I keep getting a message saying permission denied in my terminal. How can I fix that

daventhakkar
Автор

I checked the path by typing "whereis python" in Terminal and it returns "/usr/bin/python". Should i modify your code above and replace python3 with python?

MC-zuer
Автор

I'm having the same problem as some of the other people. "whereis" won't return anything. I'm using a MacBook Pro.

I tried running the script below on Sublime, but I'm not getting anything either. Help!

import os
import sys

dhekar
Автор

Not able to get sublime to run python 3 code on windows 10. Environment variables are set, but no luck. Welcome your suggestion to fix this.

vinodh
Автор

What if I want to change from python 3.6 to python 3.8? How to go about it?

starthrashinferno
Автор

I am facing input output problem... i can not get output if i use import sys and want to print any variable using this value
code:
import sys
n = int(input("enter a number : "))

print("the number is : " + n)

output:
enter a number :


but when i enter a number, I dont get the printed line "the number is <any number>"

avijeetkarmaker
visit shbcf.ru