Sublime Forum

New comer to paths in OSX

#1

If you have time please can you help me with a problem I have, I have been trying to work around this for two days and came to the conclusion I should just ask someone

0 Likes

#2

You should post your question, otherwise we won’t be able to try and help. :slight_smile:

0 Likes

#3

Trying to build in Sublime 3.
Currently using Python 3.7.2
using the cmd type -a python3 it reads
python3 is /usr/local/bin/python3
I am also using HomeBrew
using the cmd brew doctor it reads
your system is ready to brew

Ive done some research and I need to set my path

ive saved a file as Python3.sublime-build.py
the code in the file is

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

and it outputs this after a build

/usr/local/opt/python/bin/python3.7: can’t find ‘main’ module in ‘’
[Finished in 0.1s with exit code 1]
[cmd: [’/usr/local/bin/python3’, ‘-u’, ‘’]]
[dir: /Users/drel/Desktop/Sublime Text.app/Contents/MacOS]
[path: /usr/local/opt/python/bin/python3.7libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

should /opt/ be in the line when I search for python3?

and when I don’t include the .py in the file I saved it will at least say build finished at the bottom but when I add .py to the file I saved it says no build system.

Thank you for any response

0 Likes

#4

Your problem isn’t path related, your problem is that you didn’t save the file you were working on before you tried to run it:

1 Like

#5

In Sublime on the header of the tab it reads
“Python3.sublime-build.py”
meaning thats whats the file name is currently, I also saved this file into the default place that sublime has set forth
I click Save as with the mention code above in that file
tab over to my
InputVar (“Did it work”)
Print (“InputVar”)
hit cmd b and I get that code

that is the file you are talking about correct?

0 Likes

#6

I didn’t save as with the name highlighted this was only for purposes showing my .py file saved in this path. if I used the path term correctly

0 Likes

#7

This is the command that’s specified in your build system from above:

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

The $file expands to the name of the current file when you run the build. When you run the build, it fails:

/usr/local/opt/python/bin/python3.7: can't find 'main' module in ''

Below that failure message is the diagnostic text that tells you what Sublime tried to run, and it says this:

[cmd: ['/usr/local/bin/python3', '-u', '']]

Notice that it’s identical to what the build says, but where the name of the file goes, it’s an empty string ''; that happens when the current file has not been saved. The file has no name, so $file expands out to an empty string. The command is telling python3 to execute an empty file, and the Python interpreter responds by telling you that it doesn’t know what to run because there is no file.

The name of the file you save should be Python3.sublime-build. The extension of the file (.sublime-build) tells Sublime that this is a build system that it should interpret. If you save the file as Python3.sublime-build.py, you’re telling Sublime that based on it’s extension (.py) it is a Python source file.

When the file has the name .py Sublime is trying to load it as a plugin and failing; it’s also not recognized as a build system, so when you try to build anything you get the No Build System error.

So, save your build system as Python3.sublime-build and then save your Python program as a .py in order to use that build system to run it. You don’t want to save your program in the same place as the build system, because if you do that Sublime will think it’s a plugin and try to load it. The best place for your own programs are in your home directory or your documents directory.

To head off future problems, note that you can’t use a sublime-build to execute a program that is interactive (for example if you want it to ask you your name and then print that name out). If you do that, your program will hang forever in the background and you’ll think that it’s broken, but in reality there is no way to give it keyboard input.

0 Likes