How to use python3 by default in mac?


I'm starting to use python on mac and I have a problem that I can not solve.

I have installed the latest version of python 3.6.4 in macOS High Sierra.

In sublime text I have installed the sublimeREPL package, with which I use the option: "Python - RUN current file" to run the program I am creating.

The problem is that when using this option, the version of Python that it uses is 2.7.10 that comes with defect in the mac and generates a syntax error in input ()

What can I do to make it work well?

Thank you.

asked by Crudie 17.03.2018 в 21:15

1 answer


I have found the solution to my problem and I want to share it in case someone else is in the same situation as me.

The solution I found on this page: link

1 - We have to create a "Build System" in the following way:

We go to the menu Tools / Build System / New build system ... and put the following code:

"cmd": ["python3", "-i", "-u", "$file"],
"file_regex": "^[ ]*File \"(...?)\", line ([0-9]*)",
"selector": "source.python"}

We save it as " python3.sublime-build "

2 - Let's go to the Sublime Text / Preferences / Browse Packages ...


Inside the SublimeREPL folder we went to config / Python / and opened the file " Main.sublime-menu " in sublime text .

In this file we must modify the lines like this one in which we simply add a 3 to the word python :

"cmd": ["python3", "-u", "$file_basename"],

In my case, I have modified several lines by changing it to python3, but the one that has really fixed my problem has been:

{"command": "repl_open",
                 "caption": "Python - RUN current file",
                 "id": "repl_python_run",
                 "mnemonic": "R",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": ["python3", "-u", "$file_basename"],
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python",
                    "extend_env": {"PYTHONIOENCODING": "utf-8"}

Now when I give " Python - Run current file " it works in the latest version of python and it does not give me errors that it gave me using version 2.7.10:


3.6.4 (v3.6.4: d48ecebad5, Dec 18 2017, 21:07:28)   [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]   hello world

I hope it is easy to understand and can help someone else.


answered by 18.03.2018 в 10:40