How to configure Sublime Text -- can't get it to Build

Joined
Jan 14, 2016
Messages
51
Reaction score
6
Points
8
Location
Santa Cruz Mtns foothills, Cupertino, CA
Your Mac's Specs
Mac Mini 16GB/1TB, two 4K monitors/Mojave, Mac Book/Catalina, 2nd Mini in TV room for games/surfing
I've been using IDLE to write programs in Python3 and they run fine, but I would like to switch to Sublime Text. However, I am unable to configure it.

- I downloaded the latest version and installed it in my Applications Folder. (new Mini running Mojave)

- Sublime would not run with the default Build System config file.

- I changed it per one website's suggestion to

{
"cmd": ["/usr/local/bin/python3", "-u", "$file"],
}

which is the path I get from a terminal type -a command.

Still can't get "Hello World" to print -- hit cmd-B and nothing happens. (?) No help from the Sublime website.

I know that a number of users on this site are using Sublime Text since a search reveals several references to it.

Any hints on how to configure it? I've tried all the links I've found re installing Sublime in MacOS but nobody seems to have this problem.

Thanks.

ps: hope this is not the wrong forum for this question.
 
Last edited:

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
You mention Mojave and iOS, but since Sublime Text is an editor only for macOS, Windows or Linux, how does iOS fit into the picture?

Are you trying to execute a Python script within Sublime? Does Sublime load? You are jumping all over the place so hard to follow.
 
OP
I
Joined
Jan 14, 2016
Messages
51
Reaction score
6
Points
8
Location
Santa Cruz Mtns foothills, Cupertino, CA
Your Mac's Specs
Mac Mini 16GB/1TB, two 4K monitors/Mojave, Mac Book/Catalina, 2nd Mini in TV room for games/surfing
I meant macOS.

Sublime Text loads, edits (with all the right colors, indents, etc) and saves .py files. All seems well; however, when hitting cmd-B or any of the Build menu commands nothing happens -- no terminal or shell window.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
I just installed the latest version of Sublime Text and entered the code
Code:
print ("Hello World")

I think hit CMD+b and was asked which system to use and Python was the default chosen, when I choose that it ran the program and I saw Hello World in the bottom pane.

The next time I hit CMD+b, I didn't get asked, it just ran the program again.

You said you tried going to the Tools->Build System section and choosing Python as the option and that didn't work?
 
OP
I
Joined
Jan 14, 2016
Messages
51
Reaction score
6
Points
8
Location
Santa Cruz Mtns foothills, Cupertino, CA
Your Mac's Specs
Mac Mini 16GB/1TB, two 4K monitors/Mojave, Mac Book/Catalina, 2nd Mini in TV room for games/surfing
I enter the same code. Under Tools/Build System if I choose Python3, altho it's installed I get nothing at all.

If under Tools/BuildSystem I choose Python, I get:

/usr/bin/python: can't find '__main__' module in ''
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u ""]
[dir: /Applications/Sublime Text.app/Contents/MacOS]
[path: /Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/sbin:/Users/admin1/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin]

The path is apparently all messed up here. As noted originally, Terminal reports the path to Python3 as usr/local/bin/python3.

On a previous Mac I once worked with Python for a short time using Jupyter/Anaconda. Remnants from that time seem to cause Sublime to fail to find the right path, but I don't know how to fix it.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
For me, both Python and Python3 are in /usr/bin on Catalina.

/usr/local is traditionally for 3rd party and not for stuff included with macOS.

Also, did you save the file before trying to build/run it?
 
OP
I
Joined
Jan 14, 2016
Messages
51
Reaction score
6
Points
8
Location
Santa Cruz Mtns foothills, Cupertino, CA
Your Mac's Specs
Mac Mini 16GB/1TB, two 4K monitors/Mojave, Mac Book/Catalina, 2nd Mini in TV room for games/surfing
My Python2 is in /usr/bin and Python3 is in /usr/local/bin.

Sublime will run if I choose Python under Tools/Build System. If I select Python3 I get "No Build System."

All my attempts to get Sublime to go to /usr/local/bin to use Python3 have failed.

Is it possible to move or install Python3 into /usr/bin from usr/local/bin? I would need help with that since I don't know any terminal commands other than $ type -a. Or could I use a special app to open those folders so I could move files by dragging? (I'm a newbie when it comes to hidden files.)

Without any setup or config changes IDLE uses Python3. I would prefer to use Python3 because my documentation and tutorials are all Python3.

I really appreciate your kind help here. Thanks for sticking with me.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Please try the following, go to Tool->Build System->New Build System..

In the new file that appears, enter the following:
Code:
{
    'cmd': ['/usr/local/bin/python3', '-u', '$file'],
    'file_regex': '^[ ]*File "(…*?)", line ([0-9]*)',
    'selector': 'source.python'
}

Then save that as a new file like myPython or something and then use that as your build system and see if it behaves properly or gives you errors.
 
OP
I
Joined
Jan 14, 2016
Messages
51
Reaction score
6
Points
8
Location
Santa Cruz Mtns foothills, Cupertino, CA
Your Mac's Specs
Mac Mini 16GB/1TB, two 4K monitors/Mojave, Mac Book/Catalina, 2nd Mini in TV room for games/surfing
OK, done, although I didn't know where to save it, so I put it in the default "Users" folder.

Same as before: runs if Python is selected, does not run or produce any errors if Python 3 is selected -- nothing but a brief message saying No Build System at the bottom, which quickly disappears.

How do I use "mypython" as my new Build System?
 
Last edited:

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Apologies, I actually tried what I told you to try and there is an issue with quoting, so I've fixed that and actually tested it as well. :)

The proper code is
Code:
{
    "cmd": ["/usr/local/bin/python3", "-u", "$file"],
    "file_regex": "^[ ]*File '(…*?)', line ([0-9]*)",
    "selector": "source.python"
}

Things need to be in double quotes and not single quotes. These custom build system end up in ~/Library/Application Support/Sublime Text 3/Packages/User and that's totally fine.

I save this as myPython and chose that for my file and it worked as expected. With the single quotes I had initially suggested, i just got a "No build system" message in the bottom.

Screen Shot 2020-01-28 at 5.01.30 PM.png
 
OP
I
Joined
Jan 14, 2016
Messages
51
Reaction score
6
Points
8
Location
Santa Cruz Mtns foothills, Cupertino, CA
Your Mac's Specs
Mac Mini 16GB/1TB, two 4K monitors/Mojave, Mac Book/Catalina, 2nd Mini in TV room for games/surfing
I did the same thing but myPython does not show up in the menu, which is otherwise the same as yours. (yes, I corrected the quotes)

This seems odd in that when I do a search with EasyFind the file is definitely in the same place as yours: myPython saved today 4:46pm, 146 bytes in ./Library/Application Support/Sublime Text 3/Packages/User.

I can also get there via Preferences/Browse Packages, so it's there.

Frustrating, no? If we could just get it to show up in the menu I think we'd be there...

Where does that menu get those prompts for C, Haskell, Ruby, etc?
 
Last edited:

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
It is odd that the custom build doesn't show up in the menu, I didn't have to restart or anything. I'm running Sublime Text 3.2.2, Build 3211 for reference. You might want to try restarting with the new file in place to see if it will pick it up.

As far a the built-in ones go, they are likely part of the Sublime package itself and not modifiable it seems.
 
OP
I
Joined
Jan 14, 2016
Messages
51
Reaction score
6
Points
8
Location
Santa Cruz Mtns foothills, Cupertino, CA
Your Mac's Specs
Mac Mini 16GB/1TB, two 4K monitors/Mojave, Mac Book/Catalina, 2nd Mini in TV room for games/surfing
I trashed Sublime and the dmg and started over. I re booted the machine and re-installed Sublime 3.2.2 build 3211.

myPython still does not appear in the menu.

Python code runs if Python is selected. It does not run if Python3 is selected.

Hopeless case?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top