ice_robotic77
ice_robotic77

Reputation: 21

How can I use python3 in sublime3?

I started studying the book'python crash course'. I studied setting up Python3 in sublime text, but it doesn't run properly. Here is the code:

{
     "cmd":["python3","-u","$file"]
}

I set this code to python3 in the build system. And I tried to run "hello python world!":

print("Hello Python world!)

I've tried selecting and running Python3 from my code in the build system, but it doesn't work. I don't know why it doesn't work. what should I do?

Upvotes: 2

Views: 146

Answers (1)

Antricks
Antricks

Reputation: 169

Make sure you are actually calling the Python interpreter in the command line.

On Windows, Python is normally referenced as py if it was added to %PATH% during installation.
On Linux or macOS Python 3 is normally referenced as python3.

To add Python to %PATH%, run the Python installer again, click "Modify", then activate "py launcher", click "Next" and "Install".

Use on Windows:

{
    "cmd":["py", "-u", "$file"]
}

Linux / macOS:

{
    "cmd":["python3", "-u", "$file"]
}


PS: I don't know if your Python code just has a typo here in the question, but there seems to be missing one double quote. If you are getting error messages containing "Syntax Error", forget about the py launcher. There's just a syntax error in your code. Use:

print("Hello Python World!")

Upvotes: 1

Related Questions