Sublime Forum

How to specify the path for Building with Python?

#1

hello,

I’m using Sublime Text 3 in macOS. By default Python 2.7 is installed in macOS, but I installed Python 3.6 via Homebrew. How can I tell Sublime Text to use this more recent version of Python for the Building System?

It is installed in this default Homebrew path: /usr/local/Cellar/python3/3.6.1

Thank you in advance,

Tirs

0 Likes

#2

Do you know how to run python from a terminal? I’m guessing python 3 is installed as python3.

So, you want to edit the sublime build system that is used to execute your files.

You can use PackageResourceViewer to do so.

0 Likes

#3

Thank you for the answer.

I edited the build settings for Python, to use python3 as shell command, so my python build settings look like this:

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

"env": {"PYTHONIOENCODING": "utf-8"},

"variants":
[
	{
		"name": "Syntax Check",
		"shell_cmd": "python3 -m py_compile \"${file}\"",
	}
]

}

However when I try to run with this a python script with the ASE package it yields this errors:

ModuleNotFoundError: No module named ‘ase’
[Finished in 0.0s with exit code 1]
[shell_cmd: python3 -u “/Users/tirso/SeqCuox/Calculations/CuO_slab111.py”]
[dir: /Users/tirso/SeqCuox/Calculations]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

However, if I run in terminal the command: python3 -u “/Users/tirso/SeqCuox/Calculations/CuO_slab111.py”, it runs perfectly fine.

0 Likes