Sublime Forum

Wont compile?

#1

Hi good day to everyone, This is my first time in this forum. I only got here because of a problem I’m facing… I don’t know why but even after following what youtube does, my sublime still cant run the code… I mean, it runs the first line and does take input from the user but after that nothing happens… after pressing enter after typing in the input, the caret just moves unto the next line and does nothing anymore, I can still type tho then press enter then the caret moved down next line again and NOTHING happens… I sincerely need help… I have several compilers installed but i prefer sublime cuz the UI? or its layout is much simplier

0 Likes

#2

What does your Python build look like? Unless you have installed a third party package, you can’t run any code directly within Sublime that takes input from the user because its builds are output only; so if you call for example input() in a Python program, it will hang forever because no input is ever delivered to to.

The recommended way to run such an interactive program would be to use Terminus to do so; its README on the linked page links to a YouTube video (I am the creator of the video) that describes how to convert a build system to use Terminus.

0 Likes

#3

Okay sir, I will try
I’ll update later

0 Likes

#4

hey there sir, I just recently subscribe to your channel. Your video was quite informative and was easy to understand. It’s just that there must have been something wrong that I’ve done since I got this error…

Unable to create process using ‘“C:\Users\Ace\AppData\Local\Programs\Python\Python312\ -u” C:\Users\Ace\Desktop\Python\test.py’: The system cannot find the file specified.
[Finished in 0.38s with exit code 101]

can you please help me kind sir?

0 Likes

#5

If that is the error message you’re getting, your build is invalid; it is trying to execute a program named C:\Users\Ace\AppData\Local\Programs\Python\Python312\ which it can’t do because it’s not a program, it’s a directory.

At the very least, you need a python.exe stuck onto the end to set the actual program that should be executed. There may also be extra path location that is needed.

0 Likes

#6

I updated the build into like this
{
“cmd”: [“C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0\python.exe”, “-u”, “$file”],
“file_regex”: “^[ ]File "(…?)”, line ([0-9]*)",
“selector”: “source.python”
}

and now it says access denied… I’m very sorry to be too stupid to understand these things mate… I only started learning programming

0 Likes

#7

You can’t use the \ character in sublime-build file content because it is a special character in JSON, which is the type of file that builds are. You would need to either double them all up (e.g. C:\\Program Files\\WindowsApps\\ and so on), or use / instead (e.g. C:/Program Files/WindowsApps).

I would recommend that you try using the Python build that ships directly with Sublime; instructions from books and blog posts (and other places like older SO answers) tend to provide advice on how to get things to work that is either outdated or downright incorrect now.

The build that ships with Sublime looks like this:

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

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

	"windows": {
		"cmd": ["py", "-u", "$file"],
	},

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

			"windows": {
				"cmd": ["py", "-m", "py_compile", "$file"],
			}
		}
	]
}

If you’re on windows, this will execute py to find the appropriate Python for you, so that you don’t need to figure out where it is. It requires that when you install Python that you check the box that says you want the py helper, though (It may or may not be on by default).

1 Like