-2

I'm using a Mac (OS X 10.10.2), would like to use SublimeText rather than IDLE. My issue is that I want to use Python 3.4 and SublimeText uses the 2.x Python that comes on my Mac.

I've Googled all over and tried and tried to follow guides even on this website, but I'm at a loss since I have very little knowledge of what I'm doing.

All I want is a program that will let me write, run, interact with Python 3.4, and I feel like with some tweaking I can get SublimeText to fit the bill.

EDIT:

Sorry guys I wrote this late the other night after spending hours messing with sublimetext, my brain was gravy.

Anyways I'll try to be more specific. I'm running OS X 10.10.2 with SublimeText2 and SublimeRepl installed. Currently, ST2 is running Python 2, but I want to run 3.4 (which I have installed from python.org) along with SublimeREPL, that way I can fully replace Python IDLE with ST2 for my class.

Quote from the thread linked above:

The first option would be to copy that Main.sublime-menu file into your local user configuration folder, if you already have one there, you will need to merge both contents. Replace all the python calls by python3, and adjust the caption properties to mention Python 3 (e.g. Python 3 - RUN current file).

Now, when you launch the command launcher via Cmd+Shift+P (should be the keyboard shortcut in OSX, right?), then you can type Python 3 and your new commands using the python3 executable should pop up.

Based on this, it seems I need to go into main.sublime-menu and copy the contents into my "local user configuration folder", but I don't know if this means Preferences > Settings - User or Preferences > Package Settings > SublimeREPL > Settings - User

Here is my main.sublime-menu as it sits. What all needs to be changed to python3 as mentioned in the quote above in order for ST2 to use python 3.4? [ { "id": "tools", "children": [{ "caption": "SublimeREPL", "mnemonic": "r", "id": "SublimeREPL", "children": [ {"caption": "Python", "id": "Python",

                 "children":[
                    {"command": "repl_open",
                     "caption": "Python",
                     "id": "repl_python",
                     "mnemonic": "p",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python", "-i", "-u"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "python_virtualenv_repl",
                     "id": "python_virtualenv_repl",
                     "caption": "Python - virtualenv"},
                    {"command": "repl_open",
                     "caption": "Python - PDB current file",
                     "id": "repl_python_pdb",
                     "mnemonic": "d",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python", "-i", "-u", "-m", "pdb", "$file_basename"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "repl_open",
                     "caption": "Python - RUN current file",
                     "id": "repl_python_run",
                     "mnemonic": "d",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python", "-u", "$file_basename"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "repl_open",
                     "caption": "Python - IPython",
                     "id": "repl_python_ipython",
                     "mnemonic": "p",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "autocomplete_server": true,
                        "cmd": {
                            "osx": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                            "linux": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                            "windows": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"]
                        },
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {
                            "PYTHONIOENCODING": "utf-8",
                            "SUBLIMEREPL_EDITOR": "$editor"
                        }
                    }
                    }
                ]}
            ]
        }]
    }
]

I hope this is a little more specific, I'm very new at this and have only the faintest grasp of what the hell I'm doing. Any help is greatly appreciated, if this isn't specific enough let me know. Thanks!

Community
  • 1
  • 1
  • This could be closed for multiple reasons: 1) Tools recommendation 2) Too broad; 3) Primarily opinion based. – George Stocker Feb 12 '15 at 18:21
  • See also http://stackoverflow.com/q/11313131/3001761, http://stackoverflow.com/q/23903415/3001761, ... It's impossible to provide more help, as you haven't explained what you've actually done and what the problem with it is. What exactly are you stuck on? – jonrsharpe Feb 12 '15 at 18:23

2 Answers2

1

This is what custom build systems are for. Here is my system for running python scripts without creating .pyc files:

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

cmd is the bash command to run, so you would replace python with python3, or the path to your python 3 executable. If you want to create .pyc files, you can remove the -B argument.

Save this in a file called python3.sublime-build, and place the file in your user package.

Darrick Herwehe
  • 3,553
  • 1
  • 21
  • 30
0

You need to make some change in this file: Main.Sublime-menu.

1st step: find / -iname 'Main.sublime-menu' in the terminal to find out where this file is stored. you will get a big list of directories but you should find this one /Library/Application Support/Sublime Text 3/Packages/SublimeREPL/config/Python/Main.sublime-menu.

2nd step: open above Main.sublime-menu file. only change 'python' to 'python3' in the line starts with "cmd". Then save and try.

Hope you will get success.